public static void validateHostnameOrIpAddress ( X509Certificate certificate , String hostname ) throws UaException { boolean dnsNameMatches = validateSubjectAltNameField ( certificate , SUBJECT_ALT_NAME_DNS_NAME , hostname :: equals ) ; boolean ipAddressMatches = validateSubjectAltNameField ( certificate , SUBJECT_ALT_NAME_IP_ADDRESS , hostname :: equals ) ; if ( ! ( dnsNameMatches || ipAddressMatches ) ) { throw new UaException ( StatusCodes . Bad_CertificateHostNameInvalid ) ; } }
Validate that the hostname used in the endpoint URL matches either the SubjectAltName DNSName or IPAddress in the given certificate .