@Test void buildTlsConfig_shouldUseCorrectTlsConfigValues() { TlsConfig tlsConfig = XConfig.buildTlsConfig( ConfigFactory.parseResources(XConfig.class, "xrpc.conf").getConfig("tls")); List<String> defaultSupportedProtocols = tlsConfig.getCiphers(); assertEquals(6, defaultSupportedProtocols.size()); for (String protocol : defaultSupportedProtocols) { assertTrue(SUPPORTED_PROTOCOLS.contains(protocol)); } ApplicationProtocolConfig applicationProtocolConfig = tlsConfig.getAlpnConfig(); assertEquals( SUPPORTED_PROTOCOLS_IN_PREFERENCE_ORDER, applicationProtocolConfig.supportedProtocols()); assertEquals(NO_ADVERTISE, applicationProtocolConfig.selectorFailureBehavior()); assertEquals(ACCEPT, applicationProtocolConfig.selectedListenerFailureBehavior()); assertEquals(ALPN, applicationProtocolConfig.protocol()); assertTrue(tlsConfig.isLogInsecureConfig()); assertTrue(tlsConfig.isUseSsl()); assertEquals(ClientAuth.OPTIONAL, tlsConfig.getClientAuth()); assertFalse(tlsConfig.isEnableOcsp()); assertEquals(0, tlsConfig.getSessionTimeout()); assertEquals(0, tlsConfig.getSessionCacheSize()); assertEquals(SslProvider.OPENSSL, tlsConfig.getSslProvider()); }
@VisibleForTesting static TlsConfig buildTlsConfig(Config config) { TlsConfig.Builder configBuilder = TlsConfig.builderFrom(config); if (!config.hasPath("privateKeyPath") || !config.hasPath("x509CertPath")) { log.info( "Private key path or x509 certificate path not defined. " + "Generating self signed certificate."); SelfSignedCertificate selfSignedCert; try { selfSignedCert = new SelfSignedCertificate("localhost"); } catch (CertificateException ce) { throw new IllegalStateException("Error creating a self-signed cert", ce); } configBuilder.privateKey(selfSignedCert.key()).certificate(selfSignedCert.cert()); } return configBuilder.build(); }
XConfig { @VisibleForTesting static TlsConfig buildTlsConfig(Config config) { TlsConfig.Builder configBuilder = TlsConfig.builderFrom(config); if (!config.hasPath("privateKeyPath") || !config.hasPath("x509CertPath")) { log.info( "Private key path or x509 certificate path not defined. " + "Generating self signed certificate."); SelfSignedCertificate selfSignedCert; try { selfSignedCert = new SelfSignedCertificate("localhost"); } catch (CertificateException ce) { throw new IllegalStateException("Error creating a self-signed cert", ce); } configBuilder.privateKey(selfSignedCert.key()).certificate(selfSignedCert.cert()); } return configBuilder.build(); } }
XConfig { @VisibleForTesting static TlsConfig buildTlsConfig(Config config) { TlsConfig.Builder configBuilder = TlsConfig.builderFrom(config); if (!config.hasPath("privateKeyPath") || !config.hasPath("x509CertPath")) { log.info( "Private key path or x509 certificate path not defined. " + "Generating self signed certificate."); SelfSignedCertificate selfSignedCert; try { selfSignedCert = new SelfSignedCertificate("localhost"); } catch (CertificateException ce) { throw new IllegalStateException("Error creating a self-signed cert", ce); } configBuilder.privateKey(selfSignedCert.key()).certificate(selfSignedCert.cert()); } return configBuilder.build(); } XConfig();  XConfig(Config configOverrides); }
XConfig { @VisibleForTesting static TlsConfig buildTlsConfig(Config config) { TlsConfig.Builder configBuilder = TlsConfig.builderFrom(config); if (!config.hasPath("privateKeyPath") || !config.hasPath("x509CertPath")) { log.info( "Private key path or x509 certificate path not defined. " + "Generating self signed certificate."); SelfSignedCertificate selfSignedCert; try { selfSignedCert = new SelfSignedCertificate("localhost"); } catch (CertificateException ce) { throw new IllegalStateException("Error creating a self-signed cert", ce); } configBuilder.privateKey(selfSignedCert.key()).certificate(selfSignedCert.cert()); } return configBuilder.build(); } XConfig();  XConfig(Config configOverrides); Map<String, List<Double>> getClientRateLimitOverride(); }
XConfig { @VisibleForTesting static TlsConfig buildTlsConfig(Config config) { TlsConfig.Builder configBuilder = TlsConfig.builderFrom(config); if (!config.hasPath("privateKeyPath") || !config.hasPath("x509CertPath")) { log.info( "Private key path or x509 certificate path not defined. " + "Generating self signed certificate."); SelfSignedCertificate selfSignedCert; try { selfSignedCert = new SelfSignedCertificate("localhost"); } catch (CertificateException ce) { throw new IllegalStateException("Error creating a self-signed cert", ce); } configBuilder.privateKey(selfSignedCert.key()).certificate(selfSignedCert.cert()); } return configBuilder.build(); } XConfig();  XConfig(Config configOverrides); Map<String, List<Double>> getClientRateLimitOverride();  }