Sets the TLS context to use for encryption. Providing a context enables encryption. It must
have been configured with {@link GrpcSslContexts}, but options could have been overridden.
964078
public NettyServerBuilder sslContext(SslContext sslContext) {
    if (sslContext != null) {
      checkArgument(sslContext.isServer(),
          "Client SSL context can not be used for server");
      GrpcSslContexts.ensureAlpnAndH2Enabled(sslContext.applicationProtocolNegotiator());
    }
    this.sslContext = sslContext;
    return this;
  }
978076
public static SecurityContext getSecurityContext() {
        Session session = ExecutionContext.getSession();
        @SuppressWarnings("resource")
        WebSocketSession ws = session == null ? null : session.getSocket();
        return ws == null ? null
                : (SecurityContext) ws.getAttributes().get(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY);
    }
3657
private void init(SSLContextImpl ctx) {
        if (debug != null && Debug.isOn("ssl")) {
            System.out.println("Using SSLEngineImpl.");
        }

        sslContext = ctx;
        sess = SSLSessionImpl.nullSession;
        handshakeSession = null;

        /*
         * State is cs_START until we initialize the handshaker.
         *
         * Apps using SSLEngine are probably going to be server.
         * Somewhat arbitrary choice.
         */
        roleIsServer = true;
        connectionState = cs_START;
        receivedCCS = false;

        /*
         * default read and write side cipher and MAC support
         *
         * Note:  compression support would go here too
         */
        readCipher = CipherBox.NULL;
        readMAC = MAC.NULL;
        writeCipher = CipherBox.NULL;
        writeMAC = MAC.NULL;

        // default security parameters for secure renegotiation
        secureRenegotiation = false;
        clientVerifyData = new byte[0];
        serverVerifyData = new byte[0];

        enabledCipherSuites =
                sslContext.getDefaultCipherSuiteList(roleIsServer);
        enabledProtocols =
                sslContext.getDefaultProtocolList(roleIsServer);

        wrapLock = new Object();
        unwrapLock = new Object();
        writeLock = new Object();

        /*
         * Save the Access Control Context.  This will be used later
         * for a couple of things, including providing a context to
         * run tasks in, and for determining which credentials
         * to use for Subject based (JAAS) decisions
         */
        acc = AccessController.getContext();

        /*
         * All outbound application data goes through this OutputRecord,
         * other data goes through their respective records created
         * elsewhere.  All inbound data goes through this one
         * input record.
         */
        outputRecord =
            new EngineOutputRecord(Record.ct_application_data, this);
        inputRecord = new EngineInputRecord(this);
        inputRecord.enableFormatChecks();

        writer = new EngineWriter();
    }
448658
@Override
    public SSLContext getSSLContext() throws KeyManagementException, UnrecoverableKeyException,
            NoSuchAlgorithmException, KeyStoreException {

        final SSLContext context = SSLContext.getInstance("TLS");

        String httpProtocols = System.getProperty("https.protocols");
        System.setProperty("https.protocols", "TLSv1");

        if (httpProtocols != null) {
            System.setProperty("https.protocols", httpProtocols);
        }

        final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory
                .getDefaultAlgorithm());
        keyManagerFactory.init(keystore, keystorePassword.toCharArray());
        context.init(keyManagerFactory.getKeyManagers(), new TrustManager[] {
                new X509TrustManager() {
                    @Override
                    public X509Certificate[] getAcceptedIssuers() {
                        return new X509Certificate[] {};
                    }

                    @Override
                    public void checkClientTrusted(final X509Certificate[] arg0, final String arg1) {

                    }

                    @Override
                    public void checkServerTrusted(final X509Certificate[] arg0, final String arg1) {

                    }
                }
        }, new SecureRandom());

        return context;
    }
505793
final public function enableCrypto(ClientTlsContext $tlsContext = null): Promise
    {
        if (($resource = $this->getResource()) === null) {
            return new Failure(new ClosedException("The socket has been closed"));
        }

        $tlsContext = $tlsContext ?? new ClientTlsContext;

        return Internal\enableCrypto($resource, $tlsContext->toStreamContextArray());
    }
78571
public static SSLContext acceptingSslContext() {
        try {
            SSLContext sslContext = SSLContext.getInstance("SSL");
            sslContext.init(null, TRUST_MANAGERS, new SecureRandom());
            return sslContext;

        } catch (NoSuchAlgorithmException | KeyManagementException ex) {
            throw new RuntimeException("Unable to create issue-ignoring SSLContext: " + ex.getMessage(), ex);
        }
    }
1374388
public void setContext(Context context) {
        context.put(JavacTypes.class, this);
        syms = Symtab.instance(context);
        types = Types.instance(context);
    }
1004412
public void setEnabledCipherSuites(String[] suites) throws SSLException {
        if (this.isOutbound) {
            this.sslConnLink.getSSLEngine().setEnabledCipherSuites(suites);
        } else {
            throw new SocketEstablishedSSLException("Error, established setting cannot be modified.");
        }
    }
364663
def ssl_context
      @ssl_context ||= OpenSSL::SSL::SSLContext.new.tap do |context|
        context.key = @key
        context.cert = @certificate
      end
    end
789456
protected function initSecureContext()
    {
        if (!\EventUtil::sslRandPoll()) {
            Daemon::$process->log(get_class($this->pool) . ': EventUtil::sslRandPoll failed');
            $this->erroneous = true;
            return;
        }
        if (!FileSystem::checkFileReadable($this->certfile) || !FileSystem::checkFileReadable($this->pkfile)) {
            Daemon::log('Couldn\'t read ' . $this->certfile . ' or ' . $this->pkfile . ' file.  To generate a key' . PHP_EOL
                . 'and self-signed certificate, run' . PHP_EOL
                . '  openssl genrsa -out ' . escapeshellarg($this->pkfile) . ' 2048' . PHP_EOL
                . '  openssl req -new -key ' . escapeshellarg($this->pkfile) . '  -out cert.req' . PHP_EOL
                . '  openssl x509 -req -days 365 -in cert.req -signkey ' . escapeshellarg($this->pkfile) . '  -out ' . escapeshellarg($this->certfile));

            return;
        }
        $params = [
            \EventSslContext::OPT_LOCAL_CERT => $this->certfile,
            \EventSslContext::OPT_LOCAL_PK => $this->pkfile,
            \EventSslContext::OPT_VERIFY_PEER => $this->verifypeer,
            \EventSslContext::OPT_ALLOW_SELF_SIGNED => $this->allowselfsigned,
        ];
        if ($this->passphrase !== null) {
            $params[\EventSslContext::OPT_PASSPHRASE] = $this->passphrase;
        }
        if ($this->verifydepth !== null) {
            $params[\EventSslContext::OPT_VERIFY_DEPTH] = $this->verifydepth;
        }
        if ($this->cafile !== null) {
            $params[\EventSslContext::OPT_CA_FILE] = $this->cafile;
        }
        if ($this->tls === true) {
            $method = \EventSslContext::TLS_SERVER_METHOD;
        } elseif ($this->tls === 'v11') {
            $method = \EventSslContext::TLSv11_SERVER_METHOD;
        } elseif ($this->tls === 'v12') {
            $method = \EventSslContext::TLSv12_SERVER_METHOD;
        } elseif ($this->ssl === 'v3' || $this->ssl === true || $this->ssl === '1') {
            $method = \EventSslContext::SSLv3_SERVER_METHOD;
        } elseif ($this->ssl === 'v2') {
            $method = \EventSslContext::SSLv2_SERVER_METHOD;
        } elseif ($this->ssl === 'v23') {
            $method = \EventSslContext::SSLv23_SERVER_METHOD;
        } elseif ($this->ssl) {
            Daemon::log(get_class($this) . ': unrecognized SSL version \'' . $this->ssl . '\'');
            return;
        } else {
            return;
        }
        $this->ctx = new \EventSslContext($method, $params);
    }
99225
public B tls(File keyCertChainFile, File keyFile) throws SSLException {
        tls(keyCertChainFile, keyFile, null, sslContextBuilder -> { /* noop */ });
        return self();
    }
409357
protected void configureSsl(SslContextFactory factory, Ssl ssl,
			SslStoreProvider sslStoreProvider) {
		factory.setProtocol(ssl.getProtocol());
		configureSslClientAuth(factory, ssl);
		configureSslPasswords(factory, ssl);
		factory.setCertAlias(ssl.getKeyAlias());
		if (!ObjectUtils.isEmpty(ssl.getCiphers())) {
			factory.setIncludeCipherSuites(ssl.getCiphers());
			factory.setExcludeCipherSuites();
		}
		if (ssl.getEnabledProtocols() != null) {
			factory.setIncludeProtocols(ssl.getEnabledProtocols());
		}
		if (sslStoreProvider != null) {
			try {
				factory.setKeyStore(sslStoreProvider.getKeyStore());
				factory.setTrustStore(sslStoreProvider.getTrustStore());
			}
			catch (Exception ex) {
				throw new IllegalStateException("Unable to set SSL store", ex);
			}
		}
		else {
			configureSslKeyStore(factory, ssl);
			configureSslTrustStore(factory, ssl);
		}
	}
121669
def _create_ssl_context(cfg):
        
        ctx = ssl.SSLContext(cfg.ssl_version)
        ctx.load_cert_chain(cfg.certfile, cfg.keyfile)
        ctx.verify_mode = cfg.cert_reqs
        if cfg.ca_certs:
            ctx.load_verify_locations(cfg.ca_certs)
        if cfg.ciphers:
            ctx.set_ciphers(cfg.ciphers)
        return ctx
622705
public B tls(File keyCertChainFile, File keyFile, Consumer<SslContextBuilder> tlsCustomizer)
            throws SSLException {
        tls(keyCertChainFile, keyFile, null, tlsCustomizer);
        return self();
    }
145951
static SSLContext createSSLContext() {
    try {
      SSLContext sc = SSLContext.getInstance("SSL");
      TrustManager[] tm = {
          new X509TrustManager() {
            @SuppressLint("TrustAllX509TrustManager") @Override
            public void checkClientTrusted(X509Certificate[] paramArrayOfX509Certificate,
                String paramString) {
            }

            @SuppressLint("TrustAllX509TrustManager") @Override
            public void checkServerTrusted(X509Certificate[] paramArrayOfX509Certificate,
                String paramString) {
            }

            @Override public X509Certificate[] getAcceptedIssuers() {
              return new X509Certificate[] {};
            }
          }
      };
      sc.init(null, tm, new SecureRandom());
      return sc;
    } catch (NoSuchAlgorithmException | KeyManagementException e) {
      e.printStackTrace();
    }

    return null;
  }
632066
def enable_tls(context = SMTP.default_ssl_context)
      raise 'openssl library not installed' unless defined?(OpenSSL)
      raise ArgumentError, "SMTPS and STARTTLS is exclusive" if @starttls
      @tls = true
      @ssl_context = context
    end
1103196
public void setContext(Context context) {
        log = Log.instance(context);
        options = Options.instance(context);
        classLoaderClass = options.get("procloader");
        locations.update(log, options, Lint.instance(context), FSInfo.instance(context));
    }