Creates the SSL ServerSocket.
505985
public static ServerSocketBar create(InetAddress host, int port,
                                     int listenBacklog,
                                     boolean isEnableJni)
    throws IOException
  {
    return currentFactory().create(host, port, listenBacklog, isEnableJni);
  }
270704
public SSLSocketFactory createSslSocketFactory() {
        try {
            SSLContext sslContext = SSLContext.getInstance("TLS");
            sslContext.init(null, new TrustManager[]{this}, null);
            return sslContext.getSocketFactory();
        } catch (NoSuchAlgorithmException | KeyManagementException e) {
            throw new AssertionError(e);
        }
    }
396897
async def create_server(self, worker, protocol_factory, address=None,
                            sockets=None, idx=0):
        '''
        '''
        cfg = self.cfg
        max_requests = cfg.max_requests
        if max_requests:
            max_requests = int(lognormvariate(log(max_requests), 0.2))
        server = self.server_factory(
            protocol_factory,
            loop=worker._loop,
            max_requests=max_requests,
            keep_alive=cfg.keep_alive,
            name=self.name,
            logger=self.logger,
            server_software=cfg.server_software,
            cfg=cfg,
            idx=idx
        )
        for event in ('connection_made', 'pre_request', 'post_request',
                      'connection_lost'):
            callback = getattr(cfg, event)
            if callback != pass_through:
                server.event(event).bind(callback)
        await server.start_serving(
            sockets=sockets,
            address=address,
            backlog=cfg.backlog,
            sslcontext=self.sslcontext()
        )
        return server
866808
@Override
    public java.net.Socket createSocket() throws IOException {
        // This is the code to support outbound ssl config for an unconnected socket.
        // To make this code work, the caller side needs to set either sslProperties by using setSSLPropertiesOnThread
        // or outbound connection info with host/port information by using setOutboundConnectionInfo.
        // Either case, the thread attached information needs to be cleared after creating a socket.
        if (tc.isEntryEnabled())
            Tr.entry(tc, "createSocket");
        javax.net.ssl.SSLSocketFactory currentFactory = default_factory;
        javax.net.ssl.SSLSocket socket = null;
        java.util.Properties sslProps = props;
        if (default_constructor) {
            try {
                java.util.Properties sslPropsOnThread = getSSLPropertiesOnThread();
                java.util.Map<String, Object> currentConnectionInfo = JSSEHelper.getInstance().getOutboundConnectionInfo();
                if ((sslPropsOnThread != null) || (currentConnectionInfo != null)) {
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "either SSLProperties on thread or connectionInfo is available.");
                    if (currentConnectionInfo == null) {
                        currentConnectionInfo = new HashMap<String, Object>();
                        currentConnectionInfo.put(Constants.CONNECTION_INFO_DIRECTION, Constants.DIRECTION_OUTBOUND);
                    }
                    sslProps = getProperties(null, currentConnectionInfo, null);
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Getting SSLSocketFactory");
                    currentFactory = getSSLSocketFactory(currentConnectionInfo, sslProps);
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Got SSLSocketFactory", new Object[] { currentFactory });
                } else {
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Neither SSLProperties nor outboundConnectionInfo is set and this is an unconnected socket so create a WSSocket.");
                    java.net.Socket ws_socket = (Socket) AccessController.doPrivileged(new PrivilegedAction<Object>() {
                        @Override
                        public Object run() {

                            return (new com.ibm.ws.ssl.config.WSSocket(new java.net.Socket()));
                        }
                    });
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "createSocket");
                    return ws_socket;
                }

            } catch (Exception e) {
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "Exception getting SSLSocketFactory. Fall back to the default SSLSocketFactory", new Object[] { e });
                FFDCFilter.processException(e, getClass().getName(), "createSocket", this);
                currentFactory = default_factory;
            }
        } else {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Use default SSLSocketFactory - the default constructor was not used");
        }
        if (currentFactory != null) {
            socket = (javax.net.ssl.SSLSocket) currentFactory.createSocket();
            socket = SSLConfigManager.getInstance().setCipherListOnSocket(sslProps, socket);
        } else
            throw new javax.net.ssl.SSLException("SSLSocketFactory is null. This can occur if javax.net.ssl.SSLSocketFactory.getDefault() is called to create a socket and javax.net.ssl.* properties are not set.");

        if (tc.isEntryEnabled())
            Tr.exit(tc, "createSocket");
        return socket;
    }
1108036
def _create_socket(self):
        
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s = ssl.wrap_socket(s)
        s.connect((self.host, self.__port))
        s.settimeout(self.timeout)
        return s
1220266
protected function createSwooleServer()
    {
        $server     = $this->isWebsocket ? WebsocketServer::class : HttpServer::class;
        $config     = $this->app->config;
        $host       = $config->get('swoole.server.host');
        $port       = $config->get('swoole.server.port');
        $socketType = $config->get('swoole.server.socket_type', SWOOLE_SOCK_TCP);
        $mode       = $config->get('swoole.server.mode', SWOOLE_PROCESS);

        static::$server = new $server($host, $port, $mode, $socketType);

        $options = $config->get('swoole.server.options');

        static::$server->set($options);
    }
1240017
public Socket createSocket() throws IOException {
        //
        // bug 6771432:
        // The Exception is used by HttpsClient to signal that
        // unconnected sockets have not been implemented.
        //
        UnsupportedOperationException uop = new
                UnsupportedOperationException();
        SocketException se =  new SocketException(
                "Unconnected sockets not implemented");
        se.initCause(uop);
        throw se;
    }
94371
public Server openSsl() throws SSLException, CertificateException {
        SelfSignedCertificate cert = new SelfSignedCertificate();
        sslContext = SslContextBuilder.forServer(cert.certificate(), cert.privateKey())
                .sslProvider(SslProvider.OPENSSL)
                .build();
        return this;
    }
1318129
def _setup_transport(self):
        """"""
        if hasattr(self, 'sslopts'):
            self.sock = ssl.wrap_socket(self.sock, **self.sslopts)
        elif hasattr(self, 'sslctx'):
            self.sock = self.sslctx.wrap_socket(self.sock,
                                                server_hostname=self.hostname)
        else:
            self.sock = ssl.wrap_socket(self.sock)
        self.sock.do_handshake()
        self._quick_recv = self.sock.read
757204
public ServerSocketBar bind(ServerSocketBar ss)
    throws ConfigException, IOException
  {
    synchronized (_sslInitLock) {
      if (_stdServerSocket != null)
        throw new ConfigException(L.l("Can't create duplicte ssl factory."));

      try {
        initConfig();
      } catch (RuntimeException e) {
        e.printStackTrace();
        throw e;
      }

      _stdServerSocket = ss;

      initSSL();

      return this;
    }
  }
827388
function createOptionsForServerSpec(serverSpec) {
    var options = {
        forceNew: true,            // Make a new connection each time
        reconnection: false        // Don't try and reconnect automatically
    };

    // If the server spec contains a socketResource setting we use
    // that otherwise leave the default ('/socket.io/')
    if(serverSpec.socket.socketResource) {
        options.resource = serverSpec.socket.socketResource;
    }
    return options;
}
902035
protected function createServer()
    {
        $config = $this->getServerInitConfig();
        $this->swooleServer = new \swoole_websocket_server($config['host'], $config['port'], $config['mode'], $config['sockType']);
    }
31960
protected SSLSocket createSecureSocket(String host, int port, SecurityDomain securityDomain, Socket nestedSocket) throws NoSecurityDomainException, NoSuchAlgorithmException, KeyManagementException, UnknownHostException, IOException {
        if (!CONTEXT.isTLSEnabled())
            throw new NoSuchAlgorithmException("TLS has been disabled for ATNA connections via " + SecurityDomainManager.class.getName() + ".setSetTLSEnabled(false)");

        SSLContext ctx = null;

        // Attempt to get an instance of the first support TLS protocol
        try {
            ctx = SSLContext.getInstance(securityDomain.getJdkTlsClientProtocols()[0]);
        } catch (NoSuchAlgorithmException e) {
            securityDomain.restoreSystemEnvironment();
            throw e;
        }

        // Initialize the instance for the key and trust stores
        try {
            KeyManager[] keyMgrs = securityDomain.getKeyManagers();
            TrustManager[] trustMgrs = securityDomain.getTrustManagers();

            ctx.init(keyMgrs, trustMgrs, null);
        } catch (KeyManagementException e) {
            throw e;
        }

        SSLSocketFactory factory = ctx.getSocketFactory();
        SSLSocket socket = null;

        if (logger.isDebugEnabled()) {
            String[] supportedSuites = factory.getSupportedCipherSuites();
            logger.debug("\n\nSupported cipher suites are:");
            for (int i = 0; i < supportedSuites.length; i++) {
                logger.debug("\t" + supportedSuites[i]);
            }
        }

        int retries = 0;

        Throwable cause = null;
        // Loop to get a connection or until we've exhausted number of retries
        while (retries < CONTEXT.getConfig().getSocketRetries()) {
            try {

                if (logger.isDebugEnabled()) {
                    logger.debug("Connecting to " + host + " on port " + port +
                            " (timeout: " + CONTEXT.getConfig().getConnectTimeout() + " ms) using factory " + factory.getClass().getName());
                }

                //SocketAddress address = new InetSocketAddress(host,port);
                if (nestedSocket instanceof Socket) {
                    socket = (SSLSocket) (factory.createSocket(nestedSocket, host, port, true));
                } else {
                    socket = (SSLSocket) (factory.createSocket(host, port));
                }

                //socket.connect(address, CONTEXT.getConfig().getConnectTimeout());
                // Set amount of time to wait on socket read before timing out
                socket.setSoTimeout(CONTEXT.getConfig().getSocketTimeout());
                socket.setKeepAlive(true);

                socket.setEnabledProtocols(securityDomain.getJdkTlsClientProtocols());
                socket.setEnabledCipherSuites(securityDomain.getCipherSuites());

                if (logger.isDebugEnabled()) {
                    logger.debug("\n\nEnabled Cipher suites for connection are: ");
                    String[] suites = socket.getEnabledCipherSuites();
                    for (int i = 0; i < suites.length; i++) {
                        logger.debug("\t" + suites[i]);
                    }
                }

                // Force the TLS handshake at this point so we can catch any authentication errors
                socket.startHandshake();
                break;

            } catch (SSLHandshakeException e) {
                logger.error("Handshake failed with server " + host + " on port " + port + " reason " + e.getLocalizedMessage(), e);
                try {
                    socket.close();
                } catch (IOException e1) {
                    logger.error("Error trying to close socket for " + host + " on port " + port + " reason " + e1.getLocalizedMessage(), e1);
                }
                //securityDomain.restoreSystemEnvironment();
                throw e;
            } catch (UnknownHostException e) {
                logger.error("Unable to establish connection to " + host + " on port " + port + " reason " + e.getLocalizedMessage(), e);
                //securityDomain.restoreSystemEnvironment();
                throw e;
            } catch (SocketException e) {
                logger.error("Error connecting to " + host + " on port " + port + ". Will retry in "
                        + CONTEXT.getConfig().getSocketRetryWait() / 1000 + " seconds.", e);
                retries++;
                cause = e;

                try {
                    Thread.sleep(CONTEXT.getConfig().getSocketRetryWait());
                    continue;
                } catch (InterruptedException ie) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Sleep awoken early");
                    }
                    continue;
                }

            } catch (IOException e) {
                logger.error("Error connecting to " + host + " on port " + port + ". Will retry in "
                        + CONTEXT.getConfig().getSocketRetryWait() / 1000 + " seconds." + " reason " + e.getLocalizedMessage(), e);
                retries++;
                cause = e;

                try {
                    Thread.sleep(CONTEXT.getConfig().getSocketRetryWait());
                    continue;
                } catch (InterruptedException ie) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("Sleep awoken early");
                    }
                    continue;
                }
            }

        }

        // If socket retries exceed maximum allowed, throw an exception
        if (retries >= CONTEXT.getConfig().getSocketRetries()) {
            //securityDomain.restoreSystemEnvironment();
            logger.error("Secure Socket Connect Retries Exhausted.", cause);
            throw new ConnectException("Secure socket retries exhausted");
        }

        //securityDomain.restoreSystemEnvironment();
        return socket;
    }
1069830
private SSLSocketFactory buildSslSocketFactory() {
        try {
            KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
            keyStore.load(null, null);
            keyStore.setCertificateEntry("ca", generateCertificate());

            TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            tmf.init(keyStore);

            SSLContext context = SSLContext.getInstance("TLSv1.2");
            context.init(null, tmf.getTrustManagers(), null);
            return context.getSocketFactory();

        } catch (Exception e) {
            throw new KubernetesClientException("Failure in generating SSLSocketFactory", e);
        }
    }
306632
def _ssl_wrap_socket(self, sock):
        
        context = self._parameters['ssl_options'].get('context')
        if context is not None:
            hostname = self._parameters['ssl_options'].get('server_hostname')
            return context.wrap_socket(
                sock, do_handshake_on_connect=True,
                server_hostname=hostname
            )
        if 'ssl_version' not in self._parameters['ssl_options']:
            self._parameters['ssl_options']['ssl_version'] = (
                compatibility.DEFAULT_SSL_VERSION
            )
        return ssl.wrap_socket(
            sock, do_handshake_on_connect=True,
            **self._parameters['ssl_options']
        )
57755
public ServerSocket createServerSocket() throws IOException {
        final ServerSocket socket = getServerSocketFactory().createServerSocket(name);
        socket.bind(getSocketAddress());
        return socket;
    }
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);
    }