Skip to content

Commit

Permalink
feat(crypto): add ca cert to ratelimit tls context
Browse files Browse the repository at this point in the history
Signed-off-by: owl <ouyangjun1999@gmail.com>
  • Loading branch information
oowl committed Jun 14, 2023
1 parent 1a7e62e commit 92c7107
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/utils/pointer"

// "k8s.io/apimachinery/pkg/api/resource"
// "k8s.io/utils/pointer"
gwapiv1b1 "sigs.k8s.io/gateway-api/apis/v1beta1"
"sigs.k8s.io/yaml"

Expand Down
9 changes: 9 additions & 0 deletions internal/xds/translator/ratelimit.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const (
rateLimitClientTLSCertFilename = "/certs/tls.crt"
// rateLimitClientTLSKeyFilename is the ratelimit key file.
rateLimitClientTLSKeyFilename = "/certs/tls.key"
// rateLimitClientTLSCACertFilename is the ratelimit ca cert file.
rateLimitClientTLSCACertFilename = "/certs/ca.crt"
)

// patchHCMWithRateLimit builds and appends the Rate Limit Filter to the HTTP connection manager
Expand Down Expand Up @@ -304,6 +306,13 @@ func buildRateLimitTLSocket() (*corev3.TransportSocket, error) {
tlsCtx := &tlsv3.UpstreamTlsContext{
CommonTlsContext: &tlsv3.CommonTlsContext{
TlsCertificates: []*tlsv3.TlsCertificate{},
ValidationContextType: &tlsv3.CommonTlsContext_ValidationContext{
ValidationContext: &tlsv3.CertificateValidationContext{
TrustedCa: &corev3.DataSource{
Specifier: &corev3.DataSource_Filename{Filename: rateLimitClientTLSCACertFilename},
},
},
},
},
}

Expand Down

0 comments on commit 92c7107

Please sign in to comment.