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"
|
2024-02-08 09:20:01 -05:00
|
|
|
"log/slog"
|
2022-06-28 11:03:28 -04:00
|
|
|
"net"
|
2024-02-08 09:20:01 -05:00
|
|
|
"os"
|
2022-06-28 11:03:28 -04:00
|
|
|
"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
|
|
|
)
|
|
|
|
|
|
|
|
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()
|
2024-02-08 09:20:01 -05:00
|
|
|
log := logger.NewJSONLogger(logger.VerbosityFromInt(*verbosity))
|
2022-06-28 11:03:28 -04:00
|
|
|
|
2024-02-08 09:20:01 -05:00
|
|
|
log.With(slog.String("version", constants.BinaryVersion().String()), slog.String("attestationVariant", *attestationVariant)).
|
|
|
|
Info("Constellation Verification Service")
|
2022-06-28 11:03:28 -04:00
|
|
|
|
2023-03-29 03:30:13 -04:00
|
|
|
variant, err := variant.FromString(*attestationVariant)
|
2023-03-14 06:46:27 -04:00
|
|
|
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)
|
2023-03-14 06:46:27 -04:00
|
|
|
}
|
2024-02-08 09:20:01 -05:00
|
|
|
issuer, err := choose.Issuer(variant, log.WithGroup("issuer"))
|
2023-03-14 06:46:27 -04:00
|
|
|
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)
|
2022-06-28 11:03:28 -04:00
|
|
|
}
|
|
|
|
|
2024-02-08 09:20:01 -05:00
|
|
|
server := server.New(log.WithGroup("server"), issuer)
|
2022-06-28 11:03:28 -04:00
|
|
|
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)
|
2022-06-28 11:03:28 -04:00
|
|
|
}
|
|
|
|
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)
|
2022-06-28 11:03:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2022-06-28 11:03:28 -04:00
|
|
|
}
|
|
|
|
}
|