Skip to content

Commit

Permalink
Guard private key upload to not accept PEM certs with headers (i.e. l…
Browse files Browse the repository at this point in the history
…ikely encrypted). Resolves #41.
  • Loading branch information
jessepeterson committed Apr 5, 2022
1 parent 105d0df commit 79dd081
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion http/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,11 @@ func StorePushCertHandler(storage storage.PushCertStore, logger log.Logger) http
topic, err = cryptoutil.TopicFromCert(cert)
}
case "RSA PRIVATE KEY", "PRIVATE KEY":
pemKey = pem.EncodeToMemory(block)
if len(block.Headers) > 0 {
err = fmt.Errorf("private key PEM headers present: may be encrypted")
} else {
pemKey = pem.EncodeToMemory(block)
}
default:
err = fmt.Errorf("unrecognized PEM type: %q", block.Type)
}
Expand Down

0 comments on commit 79dd081

Please sign in to comment.