mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-27 00:19:36 -05:00
5bad5f768b
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
65 lines
2.1 KiB
Go
65 lines
2.1 KiB
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"flag"
|
|
"net"
|
|
"strconv"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/aws"
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/azure/snp"
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/gcp"
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/qemu"
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
|
"github.com/edgelesssys/constellation/v2/internal/constants"
|
|
"github.com/edgelesssys/constellation/v2/internal/logger"
|
|
"github.com/edgelesssys/constellation/v2/verify/server"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func main() {
|
|
provider := flag.String("cloud-provider", "", "cloud service provider this binary is running on")
|
|
verbosity := flag.Int("v", 0, logger.CmdLineVerbosityDescription)
|
|
|
|
flag.Parse()
|
|
log := logger.New(logger.JSONLog, logger.VerbosityFromInt(*verbosity))
|
|
|
|
log.With(zap.String("version", constants.VersionInfo()), zap.String("cloudProvider", *provider)).
|
|
Infof("Constellation Verification Service")
|
|
|
|
var issuer server.AttestationIssuer
|
|
switch cloudprovider.FromString(*provider) {
|
|
case cloudprovider.AWS:
|
|
issuer = aws.NewIssuer(log)
|
|
case cloudprovider.GCP:
|
|
issuer = gcp.NewIssuer(log)
|
|
case cloudprovider.Azure:
|
|
issuer = snp.NewIssuer(log) // TODO: dynamic selection
|
|
case cloudprovider.QEMU:
|
|
issuer = qemu.NewIssuer(log)
|
|
default:
|
|
log.With(zap.String("cloudProvider", *provider)).Fatalf("Unknown cloud provider")
|
|
}
|
|
|
|
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")
|
|
}
|
|
}
|