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

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

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

SSLEngine.getEnabledCipherSuites介绍

[英]Returns the SSL cipher suite names that are enabled in this engine instance.
[中]返回在此引擎实例中启用的SSL密码套件名称。

代码示例

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. /**
  2. * Returns the names of all encryption cipher suites that are enabled by default.
  3. *
  4. * @return An array of cipher suite names. Not expected to be empty.
  5. */
  6. public static List<String> getDefaultCipherSuites() 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().getEnabledCipherSuites() );
  12. }

代码示例来源:origin: TooTallNate/Java-WebSocket

  1. @Override
  2. public ByteChannel wrapChannel( SocketChannel channel, SelectionKey key ) throws IOException {
  3. SSLEngine e = sslcontext.createSSLEngine();
  4. /*
  5. * See https://github.com/TooTallNate/Java-WebSocket/issues/466
  6. *
  7. * We remove TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 from the enabled ciphers since it is just available when you patch your java installation directly.
  8. * E.g. firefox requests this cipher and this causes some dcs/instable connections
  9. */
  10. List<String> ciphers = new ArrayList<String>( Arrays.asList(e.getEnabledCipherSuites()));
  11. ciphers.remove("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256");
  12. e.setEnabledCipherSuites( ciphers.toArray( new String[ciphers.size()] ) );
  13. e.setUseClientMode( false );
  14. return new SSLSocketChannel2( channel, e, exec, key );
  15. }

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

  1. private static List<String> defaultCiphers(SSLEngine engine, Set<String> supportedCiphers) {
  2. List<String> ciphers = new ArrayList<String>();
  3. addIfSupported(supportedCiphers, ciphers, DEFAULT_CIPHER_SUITES);
  4. useFallbackCiphersIfDefaultIsEmpty(ciphers, engine.getEnabledCipherSuites());
  5. return ciphers;
  6. }

代码示例来源: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: eclipse-vertx/vert.x

  1. @Test
  2. public void testPreserveEnabledCipherSuitesOrder() throws Exception {
  3. SSLContext context = SSLContext.getInstance("TLS");
  4. context.init(null, null, null);
  5. SSLEngine engine = context.createSSLEngine();
  6. HttpServerOptions options = new HttpServerOptions();
  7. for (String suite : engine.getEnabledCipherSuites()) {
  8. options.addEnabledCipherSuite(suite);
  9. }
  10. assertEquals(new ArrayList<>(options.getEnabledCipherSuites()), Arrays.asList(engine.getEnabledCipherSuites()));
  11. assertEquals(new ArrayList<>(new HttpServerOptions(options).getEnabledCipherSuites()), Arrays.asList(engine.getEnabledCipherSuites()));
  12. JsonObject json = options.toJson();
  13. assertEquals(new ArrayList<>(new HttpServerOptions(json).getEnabledCipherSuites()), Arrays.asList(engine.getEnabledCipherSuites()));
  14. SSLHelper helper = new SSLHelper(options, Cert.SERVER_JKS.get(), null);
  15. assertEquals(Arrays.asList(helper.createEngine((VertxInternal) vertx).getEnabledCipherSuites()), Arrays.asList(engine.getEnabledCipherSuites()));
  16. }

代码示例来源: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: eclipse-vertx/vert.x

  1. @Test
  2. public void testUseJdkCiphersWhenNotSpecified() throws Exception {
  3. SSLContext context = SSLContext.getInstance("TLS");
  4. context.init(null, null, null);
  5. SSLEngine engine = context.createSSLEngine();
  6. String[] expected = engine.getEnabledCipherSuites();
  7. SSLHelper helper = new SSLHelper(new HttpClientOptions(),
  8. Cert.CLIENT_JKS.get(),
  9. Trust.SERVER_JKS.get());
  10. SslContext ctx = helper.getContext((VertxInternal) vertx);
  11. assertEquals(new HashSet<>(Arrays.asList(expected)), new HashSet<>(ctx.cipherSuites()));
  12. }

代码示例来源: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. }

相关文章