Upgrades given Socket to be a SSLSocket.

@throws IOException if an IO error was encountered during the upgrade handshake.
@throws RuntimeException if the upgrade negotiation failed.
193545
public static SSLSocket upgrade(SSLSocketFactory sslSocketFactory,
      HostnameVerifier hostnameVerifier, Socket socket, String host, int port,
      ConnectionSpec spec) throws IOException {
    Preconditions.checkNotNull(sslSocketFactory, "sslSocketFactory");
    Preconditions.checkNotNull(socket, "socket");
    Preconditions.checkNotNull(spec, "spec");
    SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(
        socket, host, port, true /* auto close */);
    spec.apply(sslSocket, false);
    String negotiatedProtocol = OkHttpProtocolNegotiator.get().negotiate(
        sslSocket, host, spec.supportsTlsExtensions() ? TLS_PROTOCOLS : null);
    Preconditions.checkState(
        TLS_PROTOCOLS.contains(Protocol.get(negotiatedProtocol)),
        "Only " + TLS_PROTOCOLS + " are supported, but negotiated protocol is %s",
        negotiatedProtocol);

    if (hostnameVerifier == null) {
      hostnameVerifier = OkHostnameVerifier.INSTANCE;
    }
    if (!hostnameVerifier.verify(canonicalizeHost(host), sslSocket.getSession())) {
      throw new SSLPeerUnverifiedException("Cannot verify hostname: " + host);
    }
    return sslSocket;
  }
697714
public static base_response change(nitro_service client, sslfips resource) throws Exception {
		sslfips updateresource = new sslfips();
		updateresource.fipsfw = resource.fipsfw;
		return updateresource.perform_operation(client,"update");
	}
423017
def connect(self, addr):
        """"""
        # Here we assume that the socket is client-side, and not
        # connected at the time of the call.  We connect it, then wrap it.
        if self._sslobj:
            raise ValueError("attempt to connect already-connected SSLSocket!")
        socket.connect(self, addr)
        if six.PY3:
            self._sslobj = self.context._wrap_socket(self._sock, False, self.server_hostname)
        else:
            if self.ciphers is None:
                self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile,
                                            self.cert_reqs, self.ssl_version,
                                            self.ca_certs)
            else:
                self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile,
                                            self.cert_reqs, self.ssl_version,
                                            self.ca_certs, self.ciphers)
        if self.do_handshake_on_connect:
            self.do_handshake()
598352
public static base_response update(nitro_service client, sslvserver resource) throws Exception {
		sslvserver updateresource = new sslvserver();
		updateresource.vservername = resource.vservername;
		updateresource.cleartextport = resource.cleartextport;
		updateresource.dh = resource.dh;
		updateresource.dhfile = resource.dhfile;
		updateresource.dhcount = resource.dhcount;
		updateresource.ersa = resource.ersa;
		updateresource.ersacount = resource.ersacount;
		updateresource.sessreuse = resource.sessreuse;
		updateresource.sesstimeout = resource.sesstimeout;
		updateresource.cipherredirect = resource.cipherredirect;
		updateresource.cipherurl = resource.cipherurl;
		updateresource.sslv2redirect = resource.sslv2redirect;
		updateresource.sslv2url = resource.sslv2url;
		updateresource.clientauth = resource.clientauth;
		updateresource.clientcert = resource.clientcert;
		updateresource.sslredirect = resource.sslredirect;
		updateresource.redirectportrewrite = resource.redirectportrewrite;
		updateresource.nonfipsciphers = resource.nonfipsciphers;
		updateresource.ssl2 = resource.ssl2;
		updateresource.ssl3 = resource.ssl3;
		updateresource.tls1 = resource.tls1;
		updateresource.tls11 = resource.tls11;
		updateresource.tls12 = resource.tls12;
		updateresource.snienable = resource.snienable;
		updateresource.pushenctrigger = resource.pushenctrigger;
		updateresource.sendclosenotify = resource.sendclosenotify;
		updateresource.dtlsprofilename = resource.dtlsprofilename;
		return updateresource.update_resource(client);
	}
22645
public static base_response update(nitro_service client, sslparameter resource) throws Exception {
		sslparameter updateresource = new sslparameter();
		updateresource.quantumsize = resource.quantumsize;
		updateresource.crlmemorysizemb = resource.crlmemorysizemb;
		updateresource.strictcachecks = resource.strictcachecks;
		updateresource.ssltriggertimeout = resource.ssltriggertimeout;
		updateresource.sendclosenotify = resource.sendclosenotify;
		updateresource.encrypttriggerpktcount = resource.encrypttriggerpktcount;
		updateresource.denysslreneg = resource.denysslreneg;
		updateresource.insertionencoding = resource.insertionencoding;
		updateresource.ocspcachesize = resource.ocspcachesize;
		updateresource.pushflag = resource.pushflag;
		updateresource.dropreqwithnohostheader = resource.dropreqwithnohostheader;
		updateresource.pushenctriggertimeout = resource.pushenctriggertimeout;
		updateresource.undefactioncontrol = resource.undefactioncontrol;
		updateresource.undefactiondata = resource.undefactiondata;
		return updateresource.update_resource(client);
	}
326355
private TSocket createTLSSocket(String host) throws TTransportException {
        TSSLTransportParameters sslParams = new TSSLTransportParameters("SSL", m_dbtls_cipher_suites);
        if (!Utils.isEmpty(m_keystore)) {
            sslParams.setKeyStore(m_keystore, m_keystorepassword);
        }
        if (!Utils.isEmpty(m_truststore)) {
            sslParams.setTrustStore(m_truststore, m_truststorepassword);
        }
        return TSSLTransportFactory.getClientSocket(host, m_dbport, m_db_timeout_millis, sslParams);
    }
331201
public void apply(SSLSocket sslSocket, boolean isFallback) {
    ConnectionSpec specToApply = supportedSpec(sslSocket, isFallback);

    sslSocket.setEnabledProtocols(specToApply.tlsVersions);

    String[] cipherSuitesToEnable = specToApply.cipherSuites;
    // null means "use default set".
    if (cipherSuitesToEnable != null) {
      sslSocket.setEnabledCipherSuites(cipherSuitesToEnable);
    }
  }
541497
public String negotiate(
      SSLSocket sslSocket, String hostname, @Nullable List<Protocol> protocols) throws IOException {
    if (protocols != null) {
      configureTlsExtensions(sslSocket, hostname, protocols);
    }
    try {
      // Force handshake.
      sslSocket.startHandshake();

      String negotiatedProtocol = getSelectedProtocol(sslSocket);
      if (negotiatedProtocol == null) {
        throw new RuntimeException("TLS ALPN negotiation failed with protocols: " + protocols);
      }
      return negotiatedProtocol;
    } finally {
      platform.afterHandshake(sslSocket);
    }
  }
775706
@Override
  public void ssl(SSLFactory sslFactory)
  {
    try {
      Objects.requireNonNull(sslFactory);
    
      SocketChannel channel = _channel;
      Objects.requireNonNull(channel);
    
      _sslSocket = sslFactory.ssl(channel);
      _sslSocket.startHandshake();
    } catch (IOException e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
  }
1191523
public static ApacheHttpTransport newTrustedTransport() throws GeneralSecurityException,
      IOException {
    // Set socket buffer sizes to 8192
    SocketConfig socketConfig =
        SocketConfig.custom()
            .setRcvBufSize(8192)
            .setSndBufSize(8192)
            .build();

    PoolingHttpClientConnectionManager connectionManager =
        new PoolingHttpClientConnectionManager(-1, TimeUnit.MILLISECONDS);

    // Disable the stale connection check (previously configured in the HttpConnectionParams
    connectionManager.setValidateAfterInactivity(-1);

    // Use the included trust store
    KeyStore trustStore = GoogleUtils.getCertificateTrustStore();
    SSLContext sslContext = SslUtils.getTlsSslContext();
    SslUtils.initSslContext(sslContext, trustStore, SslUtils.getPkixTrustManagerFactory());
    LayeredConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext);

    HttpClient client = HttpClientBuilder.create()
        .useSystemProperties()
        .setSSLSocketFactory(socketFactory)
        .setDefaultSocketConfig(socketConfig)
        .setMaxConnTotal(200)
        .setMaxConnPerRoute(20)
        .setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault()))
        .setConnectionManager(connectionManager)
        .disableRedirectHandling()
        .disableAutomaticRetries()
        .build();
    return new ApacheHttpTransport(client);
  }
131973
private Socket createSimulatedSocket(SSLSocket socket) {
        SimulatedSocketFactory.configure(socket);
        socket.setEnabledProtocols(new String[] { SSLAlgorithm.SSLv3.name(), SSLAlgorithm.TLSv1.name() } );
        //socket.setEnabledCipherSuites(new String[] { "SSL_RSA_WITH_RC4_128_MD5" });
        return new SimulatedSSLSocket(socket, streamManager);
    }
668442
public static base_response change(nitro_service client, sslcertkey resource) throws Exception {
		sslcertkey updateresource = new sslcertkey();
		updateresource.certkey = resource.certkey;
		updateresource.cert = resource.cert;
		updateresource.key = resource.key;
		updateresource.password = resource.password;
		updateresource.fipskey = resource.fipskey;
		updateresource.inform = resource.inform;
		updateresource.passplain = resource.passplain;
		updateresource.nodomaincheck = resource.nodomaincheck;
		return updateresource.perform_operation(client,"update");
	}
260727
@SuppressWarnings("unchecked")
	protected void _handshake() throws IOException {
		// do connection handshake

		PyroSerializer ser = PyroSerializer.getFor(Config.SERIALIZER);
		Map<String, Object> handshakedata = new HashMap<String, Object>();
		handshakedata.put("handshake", pyroHandshake);
		if(Config.METADATA)
			handshakedata.put("object", objectid);
		byte[] data = ser.serializeData(handshakedata);
		int flags = Config.METADATA? Message.FLAGS_META_ON_CONNECT : 0;
		Message msg = new Message(Message.MSG_CONNECT, data, ser.getSerializerId(), flags, sequenceNr, annotations(), pyroHmacKey);
		IOUtil.send(sock_out, msg.to_bytes());
		if(Config.MSG_TRACE_DIR!=null) {
			Message.TraceMessageSend(sequenceNr, msg.get_header_bytes(), msg.get_annotations_bytes(), msg.data);
		}

		// process handshake response
		msg = Message.recv(sock_in, new int[]{Message.MSG_CONNECTOK, Message.MSG_CONNECTFAIL}, pyroHmacKey);
		responseAnnotations(msg.annotations, msg.type);
		Object handshake_response = "?";
		if(msg.data!=null) {
			if((msg.flags & Message.FLAGS_COMPRESSED) != 0) {
				_decompressMessageData(msg);
			}
			try {
				ser = PyroSerializer.getFor(msg.serializer_id);
				handshake_response = ser.deserializeData(msg.data);
			} catch (Exception x) {
				msg.type=Message.MSG_CONNECTFAIL;
				handshake_response = "<not available because unsupported serialization format>";
			}
		}
		if(msg.type==Message.MSG_CONNECTOK) {
			if((msg.flags & Message.FLAGS_META_ON_CONNECT) != 0) {
				HashMap<String, Object> response_dict = (HashMap<String, Object>)handshake_response;
				HashMap<String, Object> metadata = (HashMap<String, Object>) response_dict.get("meta");
				_processMetadata(metadata);
				handshake_response = response_dict.get("handshake");
				try {
					validateHandshake(handshake_response);
				} catch (IOException x) {
					close();
					throw x;
				}
			}
		} else if (msg.type==Message.MSG_CONNECTFAIL) {
			close();
			throw new PyroException("connection rejected, reason: "+handshake_response);
		} else {
			close();
			throw new PyroException("connect: invalid msg type "+msg.type+" received");
		}
	}
575597
def _sslobj(sock):
    
    pass
    if isinstance(sock._sslobj, _ssl._SSLSocket):
        return sock._sslobj
    else:
        return sock._sslobj._sslobj
282131
@Deprecated
  public AndroidChannelBuilder sslSocketFactory(SSLSocketFactory factory) {
    try {
      OKHTTP_CHANNEL_BUILDER_CLASS
          .getMethod("sslSocketFactory", SSLSocketFactory.class)
          .invoke(delegateBuilder, factory);
      return this;
    } catch (Exception e) {
      throw new RuntimeException("Failed to invoke sslSocketFactory on delegate builder", e);
    }
  }
831423
public static SocketIOServer newInstance(int port, SSLContext sslContext) {
    SslContext nettySslContext = new JdkSslContext(sslContext, false, ClientAuth.NONE);
    return newInstance(port, nettySslContext);
  }
862915
public static SSLSocketChannel open(String peer, int port) throws IOException
    {
        try
        {
            return open(peer, port, SSLContext.getDefault());
        }
        catch (NoSuchAlgorithmException ex)
        {
            throw new IOException(ex);
        }
    }