Server certificate Subject Alternative Name of type IP Address is not taken into account in server name verification #2529
Labels
Enhancement
An enhancement to the driver. Lower priority than bugs.
Driver version
JDBC driver version (e.g. 12.8.1).
SQL Server version
Microsoft SQL Server 2022 (RTM-CU15-GDR) (KB5046059) - 16.0.4150.1 (X64)
Sep 25 2024 17:34:41
Copyright (C) 2022 Microsoft Corporation
Developer Edition (64-bit) on Linux (Ubuntu 22.04.5 LTS)
JAVA/JVM version
21.0.4
Problem description
Server certificate subject alternative name of type iPAddress is not taken into account in server name verification.
Expected behavior
If server address is entered as IP address and server certificate contain subject alternative name extension with that IP address defined connection attempt will be successful.
Actual behavior
Server name check fails.
Error message/stack trace
Any other details that can be helpful
com.microsoft.sqlserver.jdbc.SQLServerCertificateUtils.validateServerNameInCertificate
takes only constant 2 (DNS name) into account
JDBC URL:
jdbc:sqlserver://<IP_ADDRESS>:<PORT>;databaseName=<DB_NAME>;socketTimeout=60000;encrypt=true;trustServerCertificate=false;trustStore=<PATH_TO_TRUSTSTORE>;trustStorePassword=<TRUSTSTORE_PWD>
possible work around using parameter hostNameInCertificate with DNS name used in certificate
The text was updated successfully, but these errors were encountered: