cacert-gosignerclient/cmd/signerclient/main.go
Jan Dittberner da17fb69d7 Implement CRL and Health response handling
- add callback support to client and handler
- implement support for updating the CA certificates and profiles from
  health data of the signer
- implement CRL retrieval from the signer including delta CRL support
- implement error response handling
- add configurable start and interval timers for health and CRL data
2022-11-30 18:56:57 +01:00

99 lines
2.5 KiB
Go

/*
Copyright 2022 CAcert Inc.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"context"
"flag"
"os"
"github.com/sirupsen/logrus"
"git.cacert.org/cacert-gosigner/pkg/protocol"
"git.cacert.org/cacert-gosignerclient/internal/client"
"git.cacert.org/cacert-gosignerclient/internal/config"
"git.cacert.org/cacert-gosignerclient/internal/handler"
)
var (
commit = "dev"
date = "unknown"
version = "unknown"
)
const (
defaultConfigFile = "config.yaml"
)
func main() {
var (
showVersion, verbose bool
configFile, logLevel string
logger *logrus.Logger
)
logger = logrus.New()
logger.SetOutput(os.Stdout)
logger.SetLevel(logrus.InfoLevel)
logger.Infof("cacert-gosignerclient %s (%s) - build %s", version, commit, date)
flag.StringVar(&configFile, "config", defaultConfigFile, "signer client configuration file")
flag.BoolVar(&showVersion, "version", false, "show version")
flag.BoolVar(&verbose, "verbose", false, "verbose output")
flag.StringVar(&logLevel, "loglevel", "INFO", "log level")
flag.Parse()
if showVersion {
return
}
parsedLevel, err := logrus.ParseLevel(logLevel)
if err != nil {
logger.WithError(err).Fatal("could not parse log level")
}
logger.SetLevel(parsedLevel)
clientConfig, err := config.New(configFile)
if err != nil {
logger.WithError(err).Fatal("could not configure client")
}
commands := make(chan *protocol.Command)
callbacks := make(chan interface{}, client.CallBackBufferSize)
clientHandler, err := handler.New(clientConfig, logger, commands, callbacks)
if err != nil {
logger.WithError(err).Fatal("could not setup client handler")
}
signerClient, err := client.New(clientConfig, logger, clientHandler, commands, callbacks)
if err != nil {
logger.WithError(err).Fatal("could not setup client")
}
defer func() { _ = signerClient.Close() }()
logger.Info("setup complete, starting client operation")
if err = signerClient.Run(context.Background()); err != nil {
logger.WithError(err).Fatal("error in client")
}
}