arturobernalg commented on code in PR #610:
URL:
https://github.com/apache/httpcomponents-client/pull/610#discussion_r1922137280
##########
httpclient5/src/main/java/org/apache/hc/client5/http/ssl/DefaultHostnameVerifier.java:
##########
@@ -355,7 +355,26 @@ static List<SubjectName> getSubjectAltNames(final
X509Certificate cert, final in
if (o instanceof String) {
result.add(new SubjectName((String) o, type));
} else if (o instanceof byte[]) {
- // TODO ASN.1 DER encoded form
+ final byte[] bytes = (byte[]) o;
+ final String decodedValue;
+ if (type == SubjectName.IP) {
+ if (bytes.length == 4) {
+ decodedValue = byteArrayToIp(bytes); //
IPv4
+ } else if (bytes.length == 16) {
+ decodedValue = byteArrayToIPv6(bytes); //
IPv6
+ } else {
+ throw new
IllegalArgumentException("Invalid byte length for IP address: " + bytes.length);
+ }
+ } else if (type == SubjectName.DNS) {
+ throw new IllegalArgumentException("Unexpected
byte[] for DNS SAN type");
+ } else {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("Unrecognized SAN type: {}, data:
{}", type, TextUtils.toHexString(bytes));
+ }
+ decodedValue = TextUtils.toHexString(bytes);
// Fallback to hex string
Review Comment:
@ok2c please take another look
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]