mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-22 14:22:45 +01:00
X509Utils: handle CertificateParsingException in getDisplayNameFromCertificate() if certificate has no SubjectAltName extension
This fix makes the method compatible with JDK 18. Previously, it relied on the method returning `null` if the extension is not present.
This commit is contained in:
parent
4be4a3f9f8
commit
4a6219bf57
1 changed files with 9 additions and 5 deletions
|
@ -66,12 +66,16 @@ public class X509Utils {
|
|||
else if (type.equals(RFC4519Style.c))
|
||||
country = val;
|
||||
}
|
||||
final Collection<List<?>> subjectAlternativeNames = certificate.getSubjectAlternativeNames();
|
||||
String altName = null;
|
||||
if (subjectAlternativeNames != null)
|
||||
for (final List<?> subjectAlternativeName : subjectAlternativeNames)
|
||||
if ((Integer) subjectAlternativeName.get(0) == 1) // rfc822name
|
||||
altName = (String) subjectAlternativeName.get(1);
|
||||
try {
|
||||
final Collection<List<?>> subjectAlternativeNames = certificate.getSubjectAlternativeNames();
|
||||
if (subjectAlternativeNames != null)
|
||||
for (final List<?> subjectAlternativeName : subjectAlternativeNames)
|
||||
if ((Integer) subjectAlternativeName.get(0) == 1) // rfc822name
|
||||
altName = (String) subjectAlternativeName.get(1);
|
||||
} catch (CertificateParsingException e) {
|
||||
// swallow
|
||||
}
|
||||
|
||||
if (org != null) {
|
||||
return withLocation ? Joiner.on(", ").skipNulls().join(org, location, country) : org;
|
||||
|
|
Loading…
Add table
Reference in a new issue