< prev index next >

test/jdk/sun/security/ssl/X509TrustManagerImpl/CertRequestOverflow.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 94,103 **** --- 94,106 ---- SSLServerSocketFactory sslssf = getContext(true).getServerSocketFactory(); SSLServerSocket sslServerSocket = (SSLServerSocket) sslssf.createServerSocket(serverPort); serverPort = sslServerSocket.getLocalPort(); + if (debug) { + System.out.println("Server port is " + serverPort); + } // enable endpoint identification // ignore, we may test the feature when known how to parse client // hostname //SSLParameters params = sslServerSocket.getSSLParameters();
*** 151,160 **** --- 154,167 ---- } SSLSocketFactory sslsf = getContext(false).getSocketFactory(); SSLSocket sslSocket = (SSLSocket) sslsf.createSocket("localhost", serverPort); + if (debug) { + System.out.println("Connected to: " + + sslSocket.getRemoteSocketAddress()); + } // enable endpoint identification SSLParameters params = sslSocket.getSSLParameters(); params.setEndpointIdentificationAlgorithm("HTTPS"); sslSocket.setSSLParameters(params);
*** 212,222 **** clientTM = new MyExtendedX509TM((X509TrustManager)tms[0]); tms = new TrustManager[] {clientTM}; } ! SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(kmf.getKeyManagers(), tms, null); return ctx; } --- 219,229 ---- clientTM = new MyExtendedX509TM((X509TrustManager)tms[0]); tms = new TrustManager[] {clientTM}; } ! SSLContext ctx = SSLContext.getInstance("TLSv1.2"); ctx.init(kmf.getKeyManagers(), tms, null); return ctx; }
*** 241,261 **** public boolean wasServerChecked() { return serverChecked; } ! public void checkClientTrusted(X509Certificate chain[], String authType) throws CertificateException { tm.checkClientTrusted(chain, authType); } public void checkServerTrusted(X509Certificate chain[], String authType) throws CertificateException { tm.checkServerTrusted(chain, authType); } public X509Certificate[] getAcceptedIssuers() { // (hack code) increase the size of the returned array to make a // overflow CertificateRequest. List<X509Certificate> issuersList = new LinkedList<>(); X509Certificate[] issuers = tm.getAcceptedIssuers(); --- 248,270 ---- public boolean wasServerChecked() { return serverChecked; } ! @Override public void checkClientTrusted(X509Certificate chain[], String authType) throws CertificateException { tm.checkClientTrusted(chain, authType); } + @Override public void checkServerTrusted(X509Certificate chain[], String authType) throws CertificateException { tm.checkServerTrusted(chain, authType); } + @Override public X509Certificate[] getAcceptedIssuers() { // (hack code) increase the size of the returned array to make a // overflow CertificateRequest. List<X509Certificate> issuersList = new LinkedList<>(); X509Certificate[] issuers = tm.getAcceptedIssuers();
*** 266,293 **** --- 275,306 ---- } return issuersList.toArray(issuers); } + @Override public void checkClientTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { clientChecked = true; tm.checkClientTrusted(chain, authType); } + @Override public void checkServerTrusted(X509Certificate[] chain, String authType, Socket socket) throws CertificateException { serverChecked = true; tm.checkServerTrusted(chain, authType); } + @Override public void checkClientTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException { clientChecked = true; tm.checkClientTrusted(chain, authType); } + @Override public void checkServerTrusted(X509Certificate[] chain, String authType, SSLEngine engine) throws CertificateException { serverChecked = true; tm.checkServerTrusted(chain, authType); }
*** 355,364 **** --- 368,378 ---- } void startServer(boolean newThread) throws Exception { if (newThread) { serverThread = new Thread() { + @Override public void run() { try { doServerSide(); } catch (Exception e) { /*
*** 379,388 **** --- 393,403 ---- } void startClient(boolean newThread) throws Exception { if (newThread) { clientThread = new Thread() { + @Override public void run() { try { doClientSide(); } catch (Exception e) { /*
< prev index next >