Skip to content

Commit

Permalink
Merge pull request #394 from arthurscchan/null-pointer
Browse files Browse the repository at this point in the history
Exception fixing: Add handling for possible empty content for PemObject
  • Loading branch information
loosebazooka authored Mar 24, 2023
2 parents a01c405 + 478c8b3 commit 13c9b96
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sigstore-java/src/main/java/dev/sigstore/encryption/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static PublicKey parsePublicKey(byte[] keyBytes)
throw new InvalidKeySpecException("Invalid key, could not parse PEM section");
}
// special handling for PKCS1 (rsa) public key
if (section == null) {
throw new InvalidKeySpecException("Invalid key");
if ((section == null) || (section.getContent() == null)) {
throw new InvalidKeySpecException("Invalid key, empty PEM section");
}
if (section.getType().equals("RSA PUBLIC KEY")) {
ASN1Sequence sequence = ASN1Sequence.getInstance(section.getContent());
Expand Down

0 comments on commit 13c9b96

Please sign in to comment.