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"
|
|
|
|
|
2022-11-02 19:56:44 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/aws"
|
2022-09-21 07:47:57 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/azure"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/gcp"
|
|
|
|
"github.com/edgelesssys/constellation/v2/internal/attestation/qemu"
|
2022-11-02 19:56:44 -04:00
|
|
|
"github.com/edgelesssys/constellation/v2/internal/cloud/cloudprovider"
|
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() {
|
|
|
|
provider := flag.String("cloud-provider", "", "cloud service provider this binary is running on")
|
2022-10-31 09:12:38 -04:00
|
|
|
// FIXME: define flag again once its definition no longer collides with glog.
|
|
|
|
// This should happen as soon as https://github.com/google/go-sev-guest/issues/23 is merged and consumed by us.
|
|
|
|
verbosity := 0 // 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-10-31 09:12:38 -04:00
|
|
|
log := logger.New(logger.JSONLog, logger.VerbosityFromInt(verbosity))
|
2022-06-28 11:03:28 -04:00
|
|
|
|
|
|
|
log.With(zap.String("version", constants.VersionInfo), zap.String("cloudProvider", *provider)).
|
|
|
|
Infof("Constellation Verification Service")
|
|
|
|
|
|
|
|
var issuer server.AttestationIssuer
|
2022-11-02 19:56:44 -04:00
|
|
|
switch cloudprovider.FromString(*provider) {
|
|
|
|
case cloudprovider.AWS:
|
|
|
|
issuer = aws.NewIssuer()
|
|
|
|
case cloudprovider.GCP:
|
2022-06-28 11:03:28 -04:00
|
|
|
issuer = gcp.NewIssuer()
|
2022-11-02 19:56:44 -04:00
|
|
|
case cloudprovider.Azure:
|
2022-06-28 11:03:28 -04:00
|
|
|
issuer = azure.NewIssuer()
|
2022-11-02 19:56:44 -04:00
|
|
|
case cloudprovider.QEMU:
|
2022-06-28 11:03:28 -04:00
|
|
|
issuer = qemu.NewIssuer()
|
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|