Skip to content

Commit 32c934f

Browse files
authored
fix: validate PSC DNS name in server certificate (GoogleCloudPlatform#628)
1 parent b6648c4 commit 32c934f

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

alloydb-jdbc-connector/src/main/java/com/google/cloud/alloydb/ConnectionSocket.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,23 +108,14 @@ Socket connect() throws IOException {
108108
"Instance does not have an address matching type: %s", connectionConfig.getIpType()));
109109
}
110110

111-
// Use the instance's address as a HostName.
112-
String serverName = address;
113-
// TODO: use the correct address as server name once PSC DNS is populated
114-
// in all existing clusters. When that happens, delete this if statement.
115-
// https://github.com/GoogleCloudPlatform/alloydb-java-connector/issues/499
116-
if (connectionConfig.getIpType().equals(IpType.PSC)) {
117-
serverName = connectionInfo.getIpAddress();
118-
}
119-
120111
logger.debug(String.format("[%s] Connecting to instance.", address));
121112

122113
SSLParameters sslParameters = socket.getSSLParameters();
123114
// Set HTTPS as the the endpoint identification algorithm
124115
// in order to verify the identity of the certificate as
125116
// suggested at https://stackoverflow.com/a/17979954/927514
126117
sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
127-
sslParameters.setServerNames(Collections.singletonList(new SNIHostName(serverName)));
118+
sslParameters.setServerNames(Collections.singletonList(new SNIHostName(address)));
128119

129120
socket.setSSLParameters(sslParameters);
130121
socket.setKeepAlive(true);

0 commit comments

Comments
 (0)