Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zaibon committed Aug 21, 2023
1 parent d53bd00 commit e2edfe9
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 112 deletions.
60 changes: 30 additions & 30 deletions app/artifact-cas/internal/conf/conf.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions app/artifact-cas/internal/conf/conf.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ message Server {
}
message TLS {
// path to certificate and private key
string Certificate = 1;
string PrivateKey = 2;
string certificate = 1;
string private_key = 2;
}
message GRPC {
string network = 1;
string addr = 2;
google.protobuf.Duration timeout = 3;
TLS tlsConfig = 4;
TLS tls_config = 4;
}
// Regular HTTP endpoint
HTTP http = 1;
Expand Down
23 changes: 13 additions & 10 deletions app/artifact-cas/internal/server/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,20 @@ func NewGRPCServer(c *conf.Server, authConf *conf.Auth, byteService *service.Byt
if c.Grpc.Timeout != nil {
opts = append(opts, grpc.Timeout(c.Grpc.Timeout.AsDuration()))
}
cert := c.Grpc.TlsConfig.Certificate
privKey := c.Grpc.TlsConfig.PrivateKey
if cert != "" && privKey != "" {
cert, err := tls.LoadX509KeyPair(cert, privKey)
if err != nil {
return nil, err
if tlsConf := c.Grpc.GetTlsConfig(); tlsConf != nil {
cert := tlsConf.GetCertificate()
privKey := tlsConf.GetPrivateKey()
if cert != "" && privKey != "" {
cert, err := tls.LoadX509KeyPair(cert, privKey)
if err != nil {
return nil, fmt.Errorf("loading gRPC server TLS certificate: %w", err)
}
opts = append(opts, grpc.TLSConfig(&tls.Config{
Certificates: []tls.Certificate{cert},
MinVersion: tls.VersionTLS12, // gosec complains about insecure minumum version we use default value

Check failure on line 107 in app/artifact-cas/internal/server/grpc.go

View workflow job for this annotation

GitHub Actions / lint (main-module)

`minumum` is a misspelling of `minimum` (misspell)

Check failure on line 107 in app/artifact-cas/internal/server/grpc.go

View workflow job for this annotation

GitHub Actions / lint (artifact-cas)

`minumum` is a misspelling of `minimum` (misspell)
}))
}
opts = append(opts, grpc.TLSConfig(&tls.Config{
Certificates: []tls.Certificate{cert},
MinVersion: tls.VersionTLS12,
}))

Check failure on line 110 in app/artifact-cas/internal/server/grpc.go

View workflow job for this annotation

GitHub Actions / lint (main-module)

unnecessary trailing newline (whitespace)

Check failure on line 110 in app/artifact-cas/internal/server/grpc.go

View workflow job for this annotation

GitHub Actions / lint (artifact-cas)

unnecessary trailing newline (whitespace)
}
srv := grpc.NewServer(opts...)

Expand Down

0 comments on commit e2edfe9

Please sign in to comment.