Skip to content

Commit

Permalink
fix(key-usage): Fix nullpointer error
Browse files Browse the repository at this point in the history
  • Loading branch information
malikzh committed Aug 23, 2024
1 parent 4c02a25 commit 82cb024
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/kz/ncanode/wrapper/CertificateWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,19 +193,23 @@ public PublicKey getPublicKey() {
return x509Certificate.getPublicKey();
}

private Set<CertificateKeyUser> getKeyUser() {
public List<String> getExtendedKeyUsage() {
try {
return getX509Certificate().getExtendedKeyUsage().stream()
.map(CertificateKeyUser::fromOID)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toSet());
return getX509Certificate().getExtendedKeyUsage();
} catch (CertificateParsingException e) {
log.error("Certificate key user extracting error", e);
return Collections.emptySet();
return Collections.emptyList();
}
}

private Set<CertificateKeyUser> getKeyUser() {
return getExtendedKeyUsage().stream()
.map(CertificateKeyUser::fromOID)
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toSet());
}

public static Optional<CertificateWrapper> fromBase64(final String encodedCert) {
return fromBytes(Base64.getDecoder().decode(encodedCert.replaceAll("\\s", "")));
}
Expand Down

0 comments on commit 82cb024

Please sign in to comment.