javax.net.ssl.SSLEngine.getEnabledProtocols()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(171)

本文整理了Java中javax.net.ssl.SSLEngine.getEnabledProtocols()方法的一些代码示例,展示了SSLEngine.getEnabledProtocols()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。SSLEngine.getEnabledProtocols()方法的具体详情如下:
包路径:javax.net.ssl.SSLEngine
类名称:SSLEngine
方法名:getEnabledProtocols

SSLEngine.getEnabledProtocols介绍

[英]Returns the protocol version names that are enabled in this engine instance.
[中]返回在此引擎实例中启用的协议版本名称。

代码示例

代码示例来源:origin: redisson/redisson

  1. @Override
  2. public String[] getEnabledProtocols() {
  3. return engine.getEnabledProtocols();
  4. }

代码示例来源:origin: wildfly/wildfly

  1. @Override
  2. public String[] getEnabledProtocols() {
  3. return delegate.getEnabledProtocols();
  4. }

代码示例来源:origin: wildfly/wildfly

  1. @Override
  2. public String[] getEnabledProtocols() {
  3. return delegate.getEnabledProtocols();
  4. }

代码示例来源:origin: wildfly/wildfly

  1. @Override
  2. public String[] getEnabledProtocols() {
  3. return engine.getEnabledProtocols();
  4. }

代码示例来源:origin: wildfly/wildfly

  1. public String[] getEnabledProtocols() {
  2. return delegate.getEnabledProtocols();
  3. }

代码示例来源:origin: io.netty/netty

  1. @Override
  2. public String[] getEnabledProtocols() {
  3. return engine.getEnabledProtocols();
  4. }

代码示例来源:origin: wildfly/wildfly

  1. public String[] getEnabledProtocols() {
  2. return currentRef.get().getEnabledProtocols();
  3. }

代码示例来源:origin: wildfly/wildfly

  1. public String[] getEnabledProtocols() {
  2. return currentRef.get().getEnabledProtocols();
  3. }

代码示例来源:origin: wildfly/wildfly

  1. public String[] getEnabledProtocols() {
  2. return currentRef.get().getEnabledProtocols();
  3. }

代码示例来源:origin: igniterealtime/Openfire

  1. /**
  2. * Returns the names of all encryption protocols that are enabled by default.
  3. *
  4. * @return An array of protocol names. Not expected to be empty.
  5. */
  6. public static List<String> getDefaultProtocols() throws NoSuchAlgorithmException, KeyManagementException
  7. {
  8. // TODO Might want to cache the result. It's unlikely to change at runtime.
  9. final SSLContext context = SSLContext.getInstance( "TLSv1" );
  10. context.init( null, null, null );
  11. return Arrays.asList( context.createSSLEngine().getEnabledProtocols() );
  12. }

代码示例来源:origin: redisson/redisson

  1. private static String[] defaultProtocols(SSLEngine engine) {
  2. // Choose the sensible default list of protocols.
  3. final String[] supportedProtocols = engine.getSupportedProtocols();
  4. Set<String> supportedProtocolsSet = new HashSet<String>(supportedProtocols.length);
  5. for (int i = 0; i < supportedProtocols.length; ++i) {
  6. supportedProtocolsSet.add(supportedProtocols[i]);
  7. }
  8. List<String> protocols = new ArrayList<String>();
  9. addIfSupported(
  10. supportedProtocolsSet, protocols,
  11. // Do not include TLSv1.3 for now by default.
  12. SslUtils.PROTOCOL_TLS_V1_2, SslUtils.PROTOCOL_TLS_V1_1, SslUtils.PROTOCOL_TLS_V1);
  13. if (!protocols.isEmpty()) {
  14. return protocols.toArray(new String[0]);
  15. }
  16. return engine.getEnabledProtocols();
  17. }

代码示例来源:origin: igniterealtime/Openfire

  1. /**
  2. * Creates an SSL Engine that is configured to use client mode when handshaking.
  3. *
  4. * For Openfire, an engine of this mode is typically used when the server tries to connect to another server.
  5. *
  6. * These SSLEngines never send SSLV2 ClientHello messages.
  7. *
  8. * @return An initialized SSLEngine instance (never null).
  9. */
  10. public SSLEngine createClientModeSSLEngine() throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException
  11. {
  12. final SSLEngine sslEngine = createSSLEngine();
  13. sslEngine.setUseClientMode( true );
  14. final Set<String> protocols = new LinkedHashSet<>( Arrays.asList( sslEngine.getEnabledProtocols() ) );
  15. protocols.remove( "SSLv2Hello" );
  16. sslEngine.setEnabledProtocols( protocols.toArray( new String[ protocols.size() ] ) );
  17. return sslEngine;
  18. }

代码示例来源:origin: apache/flume

  1. private Optional<SSLEngine> getSslEngine(boolean useClientMode) {
  2. return getSslContext().map(sslContext -> {
  3. SSLEngine sslEngine = sslContext.createSSLEngine();
  4. sslEngine.setUseClientMode(useClientMode);
  5. sslEngine.setEnabledProtocols(
  6. getFilteredProtocols(sslEngine.getEnabledProtocols()));
  7. sslEngine.setEnabledCipherSuites(
  8. getFilteredCipherSuites(sslEngine.getEnabledCipherSuites()));
  9. return sslEngine;
  10. });
  11. }

代码示例来源:origin: dropwizard/dropwizard

  1. private void logSupportedParameters(SslContextFactory contextFactory) {
  2. if (LOGGED.compareAndSet(false, true)) {
  3. // When Jetty logs out which protocols are enabled / disabled they include tracing
  4. // information to detect if the protocol was disabled at the
  5. // JRE/lib/security/java.security level. Since we don't log this information we take the
  6. // SSLEngine from our context instead of a pristine version.
  7. //
  8. // For more info from Jetty:
  9. // https://github.com/eclipse/jetty.project/blob/93a8afcc6bd1a6e0af7bd9f967c97ae1bc3eb718/jetty-util/src/main/java/org/eclipse/jetty/util/ssl/SslContextFactory.java#L356-L360
  10. final SSLEngine engine = contextFactory.getSslContext().createSSLEngine();
  11. final Map<Boolean, List<String>> protocols = partitionSupport(
  12. engine.getSupportedProtocols(),
  13. engine.getEnabledProtocols(),
  14. contextFactory.getExcludeProtocols(),
  15. contextFactory.getIncludeProtocols()
  16. );
  17. final Map<Boolean, List<String>> ciphers = partitionSupport(
  18. engine.getSupportedCipherSuites(),
  19. engine.getEnabledCipherSuites(),
  20. contextFactory.getExcludeCipherSuites(),
  21. contextFactory.getIncludeCipherSuites()
  22. );
  23. LOGGER.info("Enabled protocols: {}", protocols.get(true));
  24. LOGGER.info("Disabled protocols: {}", protocols.get(false));
  25. LOGGER.info("Enabled cipher suites: {}", ciphers.get(true));
  26. LOGGER.info("Disabled cipher suites: {}", ciphers.get(false));
  27. }
  28. }

代码示例来源:origin: stanfordnlp/CoreNLP

  1. @Override
  2. public void configure(HttpsParameters params) {
  3. SSLContext context = getSSLContext();
  4. SSLEngine engine = context.createSSLEngine();
  5. params.setNeedClientAuth(false);
  6. params.setCipherSuites(engine.getEnabledCipherSuites());
  7. params.setProtocols(engine.getEnabledProtocols());
  8. params.setSSLParameters(context.getDefaultSSLParameters());
  9. }
  10. });

代码示例来源:origin: apache/incubator-druid

  1. @Override
  2. public void start() throws Exception
  3. {
  4. log.info("Starting Jetty Server...");
  5. server.start();
  6. if (node.isEnableTlsPort()) {
  7. // Perform validation
  8. Preconditions.checkNotNull(sslContextFactory);
  9. final SSLEngine sslEngine = sslContextFactory.newSSLEngine();
  10. if (sslEngine.getEnabledCipherSuites() == null || sslEngine.getEnabledCipherSuites().length == 0) {
  11. throw new ISE(
  12. "No supported cipher suites found, supported suites [%s], configured suites include list: [%s] exclude list: [%s]",
  13. Arrays.toString(sslEngine.getSupportedCipherSuites()),
  14. tlsServerConfig.getIncludeCipherSuites(),
  15. tlsServerConfig.getExcludeCipherSuites()
  16. );
  17. }
  18. if (sslEngine.getEnabledProtocols() == null || sslEngine.getEnabledProtocols().length == 0) {
  19. throw new ISE(
  20. "No supported protocols found, supported protocols [%s], configured protocols include list: [%s] exclude list: [%s]",
  21. Arrays.toString(sslEngine.getSupportedProtocols()),
  22. tlsServerConfig.getIncludeProtocols(),
  23. tlsServerConfig.getExcludeProtocols()
  24. );
  25. }
  26. }
  27. }

代码示例来源:origin: Netflix/zuul

  1. LOG.debug("ssl protocols enabled: {}", String.join(", ", sslHandler.engine().getEnabledProtocols()));

代码示例来源:origin: cloudfoundry/uaa

  1. public void configure(HttpsParameters params) {
  2. try {
  3. SSLContext c = SSLContext.getDefault();
  4. SSLEngine engine = c.createSSLEngine();
  5. params.setNeedClientAuth(false);
  6. params.setCipherSuites(engine.getEnabledCipherSuites());
  7. params.setProtocols(engine.getEnabledProtocols());
  8. SSLParameters defaultSSLParameters = c.getDefaultSSLParameters();
  9. params.setSSLParameters(defaultSSLParameters);
  10. } catch (Exception ex) {
  11. throw new IllegalStateException(ex);
  12. }
  13. }
  14. });

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns a new SSLParameters based on this SSLSocket's current
  3. * cipher suites, protocols, and client authentication settings.
  4. *
  5. * @since 1.6
  6. */
  7. public SSLParameters getSSLParameters() {
  8. SSLParameters p = new SSLParameters();
  9. p.setCipherSuites(getEnabledCipherSuites());
  10. p.setProtocols(getEnabledProtocols());
  11. p.setNeedClientAuth(getNeedClientAuth());
  12. p.setWantClientAuth(getWantClientAuth());
  13. return p;
  14. }

代码示例来源:origin: apache/kafka

  1. @Test
  2. public void testSslFactoryConfiguration() throws Exception {
  3. File trustStoreFile = File.createTempFile("truststore", ".jks");
  4. Map<String, Object> serverSslConfig = TestSslUtils.createSslConfig(false, true, Mode.SERVER, trustStoreFile, "server");
  5. SslFactory sslFactory = new SslFactory(Mode.SERVER);
  6. sslFactory.configure(serverSslConfig);
  7. //host and port are hints
  8. SSLEngine engine = sslFactory.createSslEngine("localhost", 0);
  9. assertNotNull(engine);
  10. String[] expectedProtocols = {"TLSv1.2"};
  11. assertArrayEquals(expectedProtocols, engine.getEnabledProtocols());
  12. assertEquals(false, engine.getUseClientMode());
  13. }

相关文章