Skip to content

Commit

Permalink
Update DidTrustListService.java (#98)
Browse files Browse the repository at this point in the history
DDCCGW-755: Exception handled for malformed trusted certificates.
  • Loading branch information
shreybansod authored Oct 31, 2024
1 parent ad9134c commit 4545061
Showing 1 changed file with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,30 @@ private String generateTrustList(List<String> countries) throws Exception {
configProperties.getDid().getIncludeFederated());

for (TrustedCertificateTrustList cert : certs) {
try {
PublicKey publicKey = cert.getParsedCertificate().getPublicKey();

PublicKey publicKey = cert.getParsedCertificate().getPublicKey();
if (publicKey instanceof RSAPublicKey rsaPublicKey) {
addTrustListEntry(trustList, cert,
new DidTrustListEntryDto.RsaPublicKeyJwk(rsaPublicKey, List.of(cert.getCertificate())));

if (publicKey instanceof RSAPublicKey rsaPublicKey) {
addTrustListEntry(trustList, cert,
new DidTrustListEntryDto.RsaPublicKeyJwk(rsaPublicKey, List.of(cert.getCertificate())));
} else if (publicKey instanceof ECPublicKey ecPublicKey) {
addTrustListEntry(trustList, cert,
new DidTrustListEntryDto.EcPublicKeyJwk(ecPublicKey, List.of(cert.getCertificate())));

} else if (publicKey instanceof ECPublicKey ecPublicKey) {
addTrustListEntry(trustList, cert,
new DidTrustListEntryDto.EcPublicKeyJwk(ecPublicKey, List.of(cert.getCertificate())));

} else {
log.error("Public Key is not RSA or EC Public Key for cert {} of country {}",
cert.getThumbprint(),
cert.getCountry());
} else {
log.error("Public Key is not RSA or EC Public Key for cert {} of country {}",
cert.getThumbprint(),
cert.getCountry());
}
} catch (Exception exception) {
String failedFor = " Domain -- " + cert.getDomain() + ","
+ " Country -- " + cert.getCountry() + ","
+ " Group -- " + cert.getGroup() + ","
+ " KID -- " + cert.getKid();

log.error("PublicKey Export Generation Failed for : [" + failedFor + " ]"
+ "\n" + " Exception : " + exception.getMessage());
}
}

Expand Down

0 comments on commit 4545061

Please sign in to comment.