Refine search
sslSocket.startHandshake(); if (verifier == null) { throw new IllegalStateException("No HostnameVerifier set. Use connectionConfiguration.setHostnameVerifier() to configure."); } else if (!verifier.verify(getXMPPServiceDomain().toString(), sslSocket.getSession())) { throw new CertificateException("Hostname verification of certificate failed. Certificate does not authenticate " + getXMPPServiceDomain());
SSLSocket socket = (SSLSocket) ssf.createSocket(_socket_, host, port, true); socket.setEnableSessionCreation(true); socket.setUseClientMode(true); socket.setEnabledProtocols(protocols); _writer = new BufferedWriter(new OutputStreamWriter(_output_, _DEFAULT_ENCODING)); if (hostnameVerifier != null && !hostnameVerifier.verify(host, socket.getSession())) { throw new SSLHandshakeException("Hostname doesn't match certificate");
private static void verifyPeerName(PGStream stream, Properties info, SSLSocket newConnection) throws PSQLException { HostnameVerifier hvn; String sslhostnameverifier = PGProperty.SSL_HOSTNAME_VERIFIER.get(info); if (sslhostnameverifier == null) { hvn = PGjdbcHostnameVerifier.INSTANCE; sslhostnameverifier = "PgjdbcHostnameVerifier"; } else { try { hvn = (HostnameVerifier) instantiate(sslhostnameverifier, info, false, null); } catch (Exception e) { throw new PSQLException( GT.tr("The HostnameVerifier class provided {0} could not be instantiated.", sslhostnameverifier), PSQLState.CONNECTION_FAILURE, e); } } if (hvn.verify(stream.getHostSpec().getHost(), newConnection.getSession())) { return; } throw new PSQLException( GT.tr("The hostname {0} could not be verified by hostnameverifier {1}.", stream.getHostSpec().getHost(), sslhostnameverifier), PSQLState.CONNECTION_FAILURE); }
sslSocket.startHandshake(); if (!route.address.hostnameVerifier.verify(route.address.uriHost, sslSocket.getSession())) { throw new IOException("Hostname '" + route.address.uriHost + "' was not verified"); out = sslSocket.getOutputStream(); in = sslSocket.getInputStream();
public void upgradeToSSL(SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier) throws IOException { SSLSocket sslSocket = sslSocketFactory.createSocket(this.socket); sslSocket.startHandshake(); socket = sslSocket; inputStream = new ByteArrayInputStream(sslSocket.getInputStream()); outputStream = new ByteArrayOutputStream(sslSocket.getOutputStream()); if (hostnameVerifier != null && !hostnameVerifier.verify(sslSocket.getInetAddress().getHostName(), sslSocket.getSession())) { throw new IdentityVerificationException("\"" + sslSocket.getInetAddress().getHostName() + "\" identity was not confirmed"); } }
@Override @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public Socket createSocket(Socket plainSocket, String host, int port, boolean autoClose) throws IOException { if (autoClose) { // we don't need the plainSocket plainSocket.close(); } SSLCertificateSocketFactory sslSocketFactory = (SSLCertificateSocketFactory) SSLCertificateSocketFactory.getDefault(0); // create and connect SSL socket, but don't do hostname/certificate verification yet SSLSocket ssl = (SSLSocket) sslSocketFactory.createSocket(InetAddress.getByName(host), port); // enable TLSv1.1/1.2 if available ssl.setEnabledProtocols(ssl.getSupportedProtocols()); // set up SNI before the handshake if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { sslSocketFactory.setHostname(ssl, host); } else { try { java.lang.reflect.Method setHostnameMethod = ssl.getClass().getMethod("setHostname", String.class); setHostnameMethod.invoke(ssl, host); } catch (Exception e) { Log.d(TlsSniSocketFactory.class.getSimpleName(), "SNI not usable: " + e); } } // verify hostname and certificate SSLSession session = ssl.getSession(); if (!hostnameVerifier.verify(host, session)) { throw new SSLPeerUnverifiedException("Cannot verify hostname: " + host); } return ssl; }
SSLParameters sslParameters = sslSocket.getSSLParameters(); sslParameters.setEndpointIdentificationAlgorithm("HTTPS"); sslSocket.setSSLParameters(sslParameters); } else { sslSocket.startHandshake(); if (!verifier.verify(xmppSession.getDomain().toString(), sslSocket.getSession())) { throw new CertificateException("Server failed to authenticate as " + xmppSession.getDomain());
@Override public boolean verify(String hostname, SSLSession session) { return hostnameVerifier.verify(hostname, session); } }
((SSLSocket) socket).setSSLParameters(sslParameters); (!hostnameVerifier.verify(host, ((SSLSocket) socket).getSession()))) { String message = String.format( "The connection to '%s' failed ssl/tls hostname verification.", host);
@Override public String authorize(SSLSocket sslSocket) throws NotAuthorizedException, IOException { final SSLSession sslSession = sslSocket.getSession(); if (hostnameVerifier.verify(nodeId, sslSession)) { final String clientId = sslSocket.getInetAddress().getHostName(); logger.debug("The request was verified with node '{}'. The hostname derived from the socket is '{}'. Authorizing Client to Load Balance data", nodeId, clientId); return clientId;
@Override public void handshakeCompleted(final HandshakeCompletedEvent event) { invoked = true; if (hostname == null) { hostname = event.getSession().getPeerHost(); } if (!hostnameVerifier.verify(hostname, event.getSession())) { try { event.getSocket().close(); } catch (IOException e) { logger.warn("Error closing SSL socket", e); } event.getSession().invalidate(); } else { verified = true; } }
HostnameVerifier allHostsValid = new InsecureHostnameVerifier();
SSLSocket socket = (SSLSocket) ssf.createSocket(_socket_, host, port, true); socket.setEnableSessionCreation(true); socket.setUseClientMode(true); socket.setEnabledProtocols(protocols); new OutputStreamWriter(_output_, encoding)); if (hostnameVerifier != null && !hostnameVerifier.verify(host, socket.getSession())) { throw new SSLHandshakeException("Hostname doesn't match certificate");
@Override public void verify(String host, SSLSocket ssl) throws IOException { if (!verifier.verify(host, ssl.getSession())) throw new SSLException(Messages.MESSAGES.hostnameVerificationFailure()); }
sslSocket.startHandshake(); if (!route.address.hostnameVerifier.verify(route.address.uriHost, sslSocket.getSession())) { throw new IOException("Hostname '" + route.address.uriHost + "' was not verified"); out = sslSocket.getOutputStream(); in = sslSocket.getInputStream();
private void connectWithSNI(SSLSocket ssl, String host) throws SSLPeerUnverifiedException { // set reasonable SSL/TLS settings before the handshake: // - enable all supported protocols ssl.setEnabledProtocols(ssl.getSupportedProtocols()); MyLog.d(this, "Using documented SNI with host name " + host); sslSocketFactory.setHostname(ssl, host); // verify hostname and certificate SSLSession session = ssl.getSession(); if (!session.isValid()) { MyLog.i(this, "Invalid session to host:'" + host + "'"); } HostnameVerifier hostnameVerifier = secure ? new BrowserCompatHostnameVerifier() : new AllowAllHostnameVerifier(); if (!hostnameVerifier.verify(host, session)) { throw new SSLPeerUnverifiedException("Cannot verify hostname: " + host); } MyLog.i(this, "Established " + session.getProtocol() + " connection with " + session.getPeerHost() + " using " + session.getCipherSuite()); }
@Override public boolean verify(final String str, final SSLSession sslSession) { return delegate.verify(tHostname, sslSession); } };
public void connect() { try { socket = new Socket(); socket.setReuseAddress(true); socket.setKeepAlive(true); socket.setTcpNoDelay(true); socket.setSoLinger(true, 0); socket.connect(new InetSocketAddress(configure.getHost(), configure.getPost()), 2000 ); socket.setSoTimeout( 60000 ); if (configure.isSsl()) { socket = configure.getSllSocketFactory().createSocket(socket, configure.getHost(), configure.getPost(), true); if (null != configure.getSslParameters()) { ((SSLSocket) socket).setSSLParameters( configure.getSslParameters() ); } if ((null != configure.getHostnameVerifier()) && (!configure.getHostnameVerifier().verify(configure.getHost(), ((SSLSocket) socket).getSession()))) { String message = String.format("The connection to '%s' failed ssl/tls hostname verification.", configure.getHost()); throw new RuntimeException(message); } } outputStream = socket.getOutputStream(); //outputStream = new StringOutputStream(new ExceptionOutputStream(outputStream)); outputStream = new StringOutputStream(outputStream); inputStream = new LedisInputStream(socket.getInputStream()); isConnection = true; } catch (IOException ex) { ex.printStackTrace(); } }
@Override public void handshakeCompleted(final HandshakeCompletedEvent event) { invoked = true; if (hostname == null) { hostname = event.getSession().getPeerHost(); } if (!hostnameVerifier.verify(hostname, event.getSession())) { try { event.getSocket().close(); } catch (IOException e) { logger.warn("Error closing SSL socket", e); } event.getSession().invalidate(); } else { verified = true; } }
private static final HostnameVerifier HostnameVerifier = new NullHostnameVerifier();