Skip to content

Commit

Permalink
adding default certificate and key paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jbsv committed Nov 22, 2024
1 parent a9aa73e commit c3ac710
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions cmd/grpc/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ func main() {
}
addr := config.Addresses[*sid]

// run server with TLS
if config.Creds.CertificateFile == "" {
log.Println("No certificate file provided, using default")
config.Creds.CertificateFile = "/opt/apir/server-cert.pem"
}
if config.Creds.KeyFile == "" {
log.Println("No key file provided, using default")
config.Creds.KeyFile = "/opt/apir/server-key.pem"
}
log.Printf("Loading server certificates from %s", config.Creds.CertificateFile)
log.Printf("Loading server key from %s", config.Creds.KeyFile)
creds, err := credentials.NewServerTLSFromFile(config.Creds.CertificateFile, config.Creds.KeyFile)
if err != nil {
log.Fatalf("failed to load servers certificates: %v", err)
}

// load the db
var db *database.DB
var dbBytes *database.Bytes
Expand Down Expand Up @@ -119,14 +135,6 @@ func main() {
// GC after db creation
runtime.GC()

// run server with TLS
log.Printf("Loading server certificates from %s", config.Creds.CertificateFile)
log.Printf("Loading server key from %s", config.Creds.KeyFile)
creds, err := credentials.NewServerTLSFromFile(config.Creds.CertificateFile, config.Creds.KeyFile)
if err != nil {
log.Fatalf("failed to load servers certificates: %v", err)
}

rpcServer := grpc.NewServer(
grpc.MaxRecvMsgSize(1024*1024*1024),
grpc.MaxSendMsgSize(1024*1024*1024),
Expand Down

0 comments on commit c3ac710

Please sign in to comment.