Skip to content

feat: Add grpc TLS support#129

Open
salrashid123 wants to merge 1 commit intocontainers:mainfrom
salrashid123:grpctls
Open

feat: Add grpc TLS support#129
salrashid123 wants to merge 1 commit intocontainers:mainfrom
salrashid123:grpctls

Conversation

@salrashid123
Copy link

This Commit PR introduces TLS support for the grpc key provider.

fixes #127

Specifically, it allows for users to configure the RootCA to trust, the ServerName for the remote host and any client certificates to use when contacting the grpc key provider.

The configuration introduces an optinoal struct with key grpc-tls which when specified will load and use the configuration values

  • root-ca-file: this is the PEM x509 rootCA which issued the grpc server certificate (default: system root CA bundle)
  • insecure-skip-verify: this bypasses TLS validation of the remote grpc server's cert (default false)
  • server-name: specifies the SNI value for the grpc server to use (default, the hostname specified in the grpc parameter)
  • cert-file: client certificate x509 cert to use (PEM format)
  • key-file: client certificate key to use (PEM format)

specifically, a sample ocicrypt could look like

{
  "key-providers": {
    "grpc-keyprovider": {
      "grpc": "your_grpc_keyprovider.domain.com:port",
      "grpc-tls": {
        "server-name": "your_grpc_keyprovider.domain.com",
        "insecure-skip-verify": false,
        "cert-file": "/path/to/client.crt",
        "key-file":"/path/to/client.key",
        "root-ca-file": "/path/to/root-ca.crt"
      }
    }
  }
}

This Commit PR introduces TLS support for the grpc key provider.

Specifically, it allows for users to configure the RootCA to trust, the ServerName for the remote host and any client certificates to use when contacting the grpc key provider.

The configuration introduces an optinoal struct with key `grpc-tls` which when specified will load and use the configuration values

* `root-ca-file`:  this is the PEM x509 rootCA which issued the grpc server certificate (default: system root CA bundle)
* `insecure-skip-verify`:  this bypasses TLS validation of the remote grpc server's cert (default false)
* `server-name`: specifies the SNI value for the grpc server to use (default, the hostname specified in the `grpc` parameter)
* `cert-file`:  client certificate x509 cert to use (PEM format)
* `key-file`:  client certificate key to use (PEM format)

specifically, a sample ocicrypt could look like

```json
{
  "key-providers": {
    "grpc-keyprovider": {
      "grpc": "your_grpc_keyprovider.domain.com:port",
      "grpc-tls": {
        "server-name": "your_grpc_keyprovider.domain.com",
        "insecure-skip-verify": false,
        "cert-file": "/path/to/client.crt",
        "key-file":"/path/to/client.key",
        "root-ca-file": "/path/to/root-ca.crt"
      }
    }
  }
}
```

Signed-off-by: sal rashid <salrashid123@gmail.com>
@salrashid123
Copy link
Author

@stefanberger allright, i'll give it another try. hopefully there's no squash needed here

@stefanberger
Copy link
Collaborator

LGTM. @lumjjb ?

var err error

if grpcTls != nil {
rootCAs := x509.NewCertPool()
Copy link
Collaborator

@stefanberger stefanberger Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be moved into the if branch because in the else branch you will overwrite rootCAs right away.

// presented by the server and any host name in that certificate.
// In this mode, TLS is susceptible to man-in-the-middle attacks.
// This should be used only for testing.
InsecureSkipVerify bool `json:"insecure-skip-verify,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does``omitempty` actually work on a boolean?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support grpc provider TLS

2 participants