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))
|
else if (type.equals(RFC4519Style.c))
|
||||||
country = val;
|
country = val;
|
||||||
}
|
}
|
||||||
final Collection<List<?>> subjectAlternativeNames = certificate.getSubjectAlternativeNames();
|
|
||||||
String altName = null;
|
String altName = null;
|
||||||
if (subjectAlternativeNames != null)
|
try {
|
||||||
for (final List<?> subjectAlternativeName : subjectAlternativeNames)
|
final Collection<List<?>> subjectAlternativeNames = certificate.getSubjectAlternativeNames();
|
||||||
if ((Integer) subjectAlternativeName.get(0) == 1) // rfc822name
|
if (subjectAlternativeNames != null)
|
||||||
altName = (String) subjectAlternativeName.get(1);
|
for (final List<?> subjectAlternativeName : subjectAlternativeNames)
|
||||||
|
if ((Integer) subjectAlternativeName.get(0) == 1) // rfc822name
|
||||||
|
altName = (String) subjectAlternativeName.get(1);
|
||||||
|
} catch (CertificateParsingException e) {
|
||||||
|
// swallow
|
||||||
|
}
|
||||||
|
|
||||||
if (org != null) {
|
if (org != null) {
|
||||||
return withLocation ? Joiner.on(", ").skipNulls().join(org, location, country) : org;
|
return withLocation ? Joiner.on(", ").skipNulls().join(org, location, country) : org;
|
||||||
|
|
Loading…
Add table
Reference in a new issue