2022-09-05 03:06:08 -04:00
|
|
|
/*
|
|
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-06-28 11:03:28 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"net"
|
|
|
|
"strconv"
|
|
|
|
|
2023-03-14 06:46:27 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/choose"
|
2023-06-09 09:41:02 -04:00
|
|
|
"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"
|
2022-06-28 11:03:28 -04:00
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-03-14 06:46:27 -04:00
|
|
|
attestationVariant := flag.String("attestation-variant", "", "attestation variant to use for aTLS connections")
|
2022-11-14 03:02:56 -05:00
|
|
|
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
|
2022-06-28 11:03:28 -04:00
|
|
|
|
2022-07-01 10:17:06 -04:00
|
|
|
flag.Parse()
|
2022-11-14 03:02:56 -05:00
|
|
|
log := logger.New(logger.JSONLog, logger.VerbosityFromInt(*verbosity))
|
2022-06-28 11:03:28 -04:00
|
|
|
|
2023-07-25 08:20:25 -04:00
|
|
|
log.With(zap.String("version", constants.BinaryVersion().String()), zap.String("attestationVariant", *attestationVariant)).
|
2022-06-28 11:03:28 -04:00
|
|
|
Infof("Constellation Verification Service")
|
|
|
|
|
2023-03-29 03:30:13 -04:00
|
|
|
variant, err := variant.FromString(*attestationVariant)
|
2023-03-14 06:46:27 -04:00
|
|
|
if err != nil {
|
|
|
|
log.With(zap.Error(err)).Fatalf("Failed to parse attestation variant")
|
|
|
|
}
|
|
|
|
issuer, err := choose.Issuer(variant, log.Named("issuer"))
|
|
|
|
if err != nil {
|
|
|
|
log.With(zap.Error(err)).Fatalf("Failed to create issuer")
|
2022-06-28 11:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
server := server.New(log.Named("server"), issuer)
|
|
|
|
httpListener, err := net.Listen("tcp", net.JoinHostPort("", strconv.Itoa(constants.VerifyServicePortHTTP)))
|
|
|
|
if err != nil {
|
|
|
|
log.With(zap.Error(err), zap.Int("port", constants.VerifyServicePortHTTP)).
|
|
|
|
Fatalf("Failed to listen")
|
|
|
|
}
|
|
|
|
grpcListener, err := net.Listen("tcp", net.JoinHostPort("", strconv.Itoa(constants.VerifyServicePortGRPC)))
|
|
|
|
if err != nil {
|
|
|
|
log.With(zap.Error(err), zap.Int("port", constants.VerifyServicePortGRPC)).
|
|
|
|
Fatalf("Failed to listen")
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := server.Run(httpListener, grpcListener); err != nil {
|
|
|
|
log.With(zap.Error(err)).Fatalf("Failed to run server")
|
|
|
|
}
|
|
|
|
}
|