Skip to content

Commit

Permalink
resolves #2
Browse files Browse the repository at this point in the history
  • Loading branch information
nhgs64 committed Jul 11, 2023
1 parent da169bb commit b6d5e07
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions internal/issuer/signer/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@ func HVCASignerFromIssuerAndSecretData(spec *sampleissuerapi.IssuerSpec, secret
if hvconfig.TLSCert, err = x509.ParseCertificate(certDER.Bytes); err != nil {
return nil, err
}
if hvconfig.TLSKey, err = x509.ParsePKCS1PrivateKey(keyDER.Bytes); err != nil {
return nil, err
// Parse the mTLS cert private key in PKCS1 or PKCS8 format
if keyDER.Type == "RSA PRIVATE KEY" {
if hvconfig.TLSKey, err = x509.ParsePKCS1PrivateKey(keyDER.Bytes); err != nil {
return nil, err
}
} else if keyDER.Type == "PRIVATE KEY" {
if hvconfig.TLSKey, err = x509.ParsePKCS8PrivateKey(keyDER.Bytes); err != nil {
return nil, err
}
} else {
return nil, errors.New("unable to determine the mTLS private key type")
}
if err = hvconfig.Validate(); err != nil {
return nil, err
Expand Down

0 comments on commit b6d5e07

Please sign in to comment.