Skip to content

Commit feec0cd

Browse files
committed
test(pqc): clean up qualified names and remove namedGroups setting
Removes fully qualified class references in BqPqcTest and deletes the namedGroups setter call on NetHttpTransport.Builder (which has been removed from the transport library). TAG=agy CONV=385b9ab5-874c-4c9a-b331-66dab51fef61
1 parent 2621f02 commit feec0cd

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

pqc-verification/src/main/java/com/google/cloud/pqc/BqPqcTest.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,23 @@
1818

1919
import com.google.api.client.http.HttpTransport;
2020
import com.google.api.client.http.javanet.NetHttpTransport;
21+
import com.google.api.client.util.SslUtils;
2122
import com.google.auth.http.HttpTransportFactory;
2223
import com.google.cloud.bigquery.BigQuery;
2324
import com.google.cloud.bigquery.BigQueryOptions;
2425
import com.google.cloud.http.HttpTransportOptions;
2526
import java.io.IOException;
27+
import java.lang.reflect.Field;
2628
import java.net.InetAddress;
2729
import java.net.Socket;
2830
import java.net.UnknownHostException;
31+
import java.security.Provider;
2932
import java.util.concurrent.atomic.AtomicReference;
3033
import javax.net.ssl.SSLContext;
34+
import javax.net.ssl.SSLSession;
3135
import javax.net.ssl.SSLSocket;
3236
import javax.net.ssl.SSLSocketFactory;
37+
import javax.net.ssl.TrustManagerFactory;
3338
import org.conscrypt.Conscrypt;
3439
import org.conscrypt.OpenSSLSocketImpl;
3540

@@ -142,22 +147,18 @@ public HttpTransport create() {
142147
NetHttpTransport.Builder builder = new NetHttpTransport.Builder();
143148

144149
// 1. Explicitly initialize Conscrypt provider
145-
java.security.Provider conscryptProvider = Conscrypt.newProvider();
150+
Provider conscryptProvider = Conscrypt.newProvider();
146151
builder.setSecurityProvider(conscryptProvider);
147152

148153
// 2. Build SSLContext and tracing socket factory using SslUtils helpers to prevent
149154
// Unknown authType: GENERIC (which is wrapped automatically inside initSslContext)
150-
javax.net.ssl.TrustManagerFactory tmf =
151-
com.google.api.client.util.SslUtils.getDefaultTrustManagerFactory(conscryptProvider);
152-
SSLContext sslContext =
153-
com.google.api.client.util.SslUtils.getTlsSslContext(conscryptProvider);
154-
com.google.api.client.util.SslUtils.initSslContext(sslContext, null, tmf);
155+
TrustManagerFactory tmf = SslUtils.getDefaultTrustManagerFactory(conscryptProvider);
156+
SSLContext sslContext = SslUtils.getTlsSslContext(conscryptProvider);
157+
SslUtils.initSslContext(sslContext, null, tmf);
155158

156159
SSLSocketFactory baseFactory = sslContext.getSocketFactory();
157160
SSLSocketFactory tracingFactory = new TracingSSLSocketFactory(baseFactory);
158161

159-
// 3. Configure builder with tracing factory and generic PQC curves
160-
builder.setNamedGroups(new String[] {"X25519MLKEM768", "X25519"});
161162
builder.setSslSocketFactory(tracingFactory);
162163

163164
return builder.build();
@@ -188,8 +189,8 @@ private Socket wrap(Socket socket) {
188189
// Direct Conscrypt check since it is a direct dependency
189190
if (rawSocket instanceof OpenSSLSocketImpl) {
190191
curve = ((OpenSSLSocketImpl) rawSocket).getCurveNameForTesting();
191-
} else if (rawSocket instanceof javax.net.ssl.SSLSocket) {
192-
curve = getSunJsseNegotiatedCurve((javax.net.ssl.SSLSocket) rawSocket);
192+
} else if (rawSocket instanceof SSLSocket) {
193+
curve = getSunJsseNegotiatedCurve((SSLSocket) rawSocket);
193194
}
194195

195196
if (curve != null) {
@@ -248,13 +249,13 @@ public Socket createSocket(
248249

249250
private static String getSunJsseNegotiatedCurve(SSLSocket socket) {
250251
try {
251-
javax.net.ssl.SSLSession session = socket.getSession();
252+
SSLSession session = socket.getSession();
252253
if (session.getClass().getName().equals("sun.security.ssl.SSLSessionImpl")) {
253-
java.lang.reflect.Field field = session.getClass().getDeclaredField("negotiatedMaxGroup");
254+
Field field = session.getClass().getDeclaredField("negotiatedMaxGroup");
254255
field.setAccessible(true);
255256
Object namedGroup = field.get(session);
256257
if (namedGroup != null) {
257-
java.lang.reflect.Field nameField = namedGroup.getClass().getDeclaredField("name");
258+
Field nameField = namedGroup.getClass().getDeclaredField("name");
258259
nameField.setAccessible(true);
259260
return (String) nameField.get(namedGroup);
260261
}

0 commit comments

Comments
 (0)