-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Inline API Gateway TLS cert code #16295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8312d33
d9a0b25
23e57d6
2b69d79
e229b33
a837edb
023323c
e5afda5
37502d4
1945da2
89a4cc5
3da3bce
887857d
1e21c56
987e6f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,6 +64,30 @@ func (e *InlineCertificateConfigEntry) Validate() error { | |
| return nil | ||
| } | ||
|
|
||
| func (e *InlineCertificateConfigEntry) Hosts() ([]string, error) { | ||
| certificateBlock, _ := pem.Decode([]byte(e.Certificate)) | ||
| if certificateBlock == nil { | ||
| return nil, errors.New("failed to parse certificate PEM") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it make sense to use a sentinel error here so callers can use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can do that in a follow-up. These are generic enough errors where we're pretty much only propagating this error back to the user or logging it and moving on, so I don't envision the need for ever trying to reflect on this or some wrapped version of it, but seeing as it's a static error string, I should probably make it into a variable that can be reused. |
||
| } | ||
|
|
||
| certificate, err := x509.ParseCertificate(certificateBlock.Bytes) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to parse certificate: %w", err) | ||
| } | ||
|
|
||
| hosts := []string{certificate.Subject.CommonName} | ||
|
|
||
| for _, name := range certificate.DNSNames { | ||
| hosts = append(hosts, name) | ||
| } | ||
|
|
||
| for _, ip := range certificate.IPAddresses { | ||
| hosts = append(hosts, ip.String()) | ||
| } | ||
|
|
||
| return hosts, nil | ||
| } | ||
|
|
||
| func (e *InlineCertificateConfigEntry) CanRead(authz acl.Authorizer) error { | ||
| var authzContext acl.AuthorizerContext | ||
| e.FillAuthzContext(&authzContext) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.