constellation/verify/cmd/main.go

63 lines
1.9 KiB
Go
Raw Normal View History

/*
Copyright (c) Edgeless Systems GmbH
SPDX-License-Identifier: AGPL-3.0-only
*/
package main
import (
"flag"
2024-02-08 09:20:01 -05:00
"log/slog"
"net"
2024-02-08 09:20:01 -05:00
"os"
"strconv"
"github.com/edgelesssys/constellation/v2/internal/attestation/choose"
"github.com/edgelesssys/constellation/v2/internal/attestation/variant"
2022-09-21 07:47:57 -04:00
"github.com/edgelesssys/constellation/v2/internal/constants"
"github.com/edgelesssys/constellation/v2/internal/logger"
"github.com/edgelesssys/constellation/v2/verify/server"
)
func main() {
attestationVariant := flag.String("attestation-variant", "", "attestation variant to use for aTLS connections")
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
flag.Parse()
2024-02-08 09:20:01 -05:00
log := logger.NewJSONLogger(logger.VerbosityFromInt(*verbosity))
2024-02-08 09:20:01 -05:00
log.With(slog.String("version", constants.BinaryVersion().String()), slog.String("attestationVariant", *attestationVariant)).
Info("Constellation Verification Service")
variant, err := variant.FromString(*attestationVariant)
if err != nil {
2024-02-08 09:20:01 -05:00
log.With(slog.Any("error", err)).Error("Failed to parse attestation variant")
os.Exit(1)
}
2024-02-08 09:20:01 -05:00
issuer, err := choose.Issuer(variant, log.WithGroup("issuer"))
if err != nil {
2024-02-08 09:20:01 -05:00
log.With(slog.Any("error", err)).Error("Failed to create issuer")
os.Exit(1)
}
2024-02-08 09:20:01 -05:00
server := server.New(log.WithGroup("server"), issuer)
httpListener, err := net.Listen("tcp", net.JoinHostPort("", strconv.Itoa(constants.VerifyServicePortHTTP)))
if err != nil {
2024-02-08 09:20:01 -05:00
log.With(slog.Any("error", err), slog.Int("port", constants.VerifyServicePortHTTP)).
Error("Failed to listen")
os.Exit(1)
}
grpcListener, err := net.Listen("tcp", net.JoinHostPort("", strconv.Itoa(constants.VerifyServicePortGRPC)))
if err != nil {
2024-02-08 09:20:01 -05:00
log.With(slog.Any("error", err), slog.Int("port", constants.VerifyServicePortGRPC)).
Error("Failed to listen")
os.Exit(1)
}
if err := server.Run(httpListener, grpcListener); err != nil {
2024-02-08 09:20:01 -05:00
log.With(slog.Any("error", err)).Error("Failed to run server")
os.Exit(1)
}
}