Skip to content

Commit 98af8a3

Browse files
committed
Update internal/gatewayapi/tls.go
Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: jvlxz <jules.dutel@gmail.com> Signed-off-by: Jules Dutel <jules.dutel@gmail.com>
1 parent d131ff5 commit 98af8a3

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

internal/gatewayapi/tls.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,15 @@ func parseCertsFromTLSSecretsData(secrets []*corev1.Secret) ([]*corev1.Secret, [
197197
return validSecrets, certs, nil
198198
}
199199

200-
// firstSupportedPrivateKeyBlock returns the first private key PEM block supported by the parsers below:
201-
// PKCS1, PKCS8, or EC. If none is found, it returns the first block so the caller can report its unsupported format.
202-
func firstSupportedPrivateKeyBlock(data []byte) *pem.Block {
200+
// privateKeyBlock returns the private key PEM block from the given data, skipping
201+
// any preceding non-key blocks such as the "EC PARAMETERS" block that tools like
202+
// OpenSSL emit ahead of an "EC PRIVATE KEY".
203+
//
204+
// If no supported private key block is found, it falls back to returning the first
205+
// block of any type (or nil if the data contains no PEM blocks at all) so the caller
206+
// can report a meaningful error about the unexpected block type rather than a generic
207+
// decode failure.
208+
func privateKeyBlock(data []byte) *pem.Block {
203209
var firstBlock *pem.Block
204210
for len(data) > 0 {
205211
block, rest := pem.Decode(data)

0 commit comments

Comments
 (0)