Java Code Examples for io.netty.handler.ssl.ApplicationProtocolConfig.SelectedListenerFailureBehavior#ACCEPT

The following examples show how to use io.netty.handler.ssl.ApplicationProtocolConfig.SelectedListenerFailureBehavior#ACCEPT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TlsUtil.java    From nitmproxy with MIT License 6 votes vote down vote up
private static ApplicationProtocolConfig applicationProtocolConfig(NitmProxyConfig config, boolean http2) {
    if (http2) {
        return new ApplicationProtocolConfig(
                Protocol.ALPN,
                SelectorFailureBehavior.NO_ADVERTISE,
                SelectedListenerFailureBehavior.ACCEPT,
                ApplicationProtocolNames.HTTP_2,
                ApplicationProtocolNames.HTTP_1_1);
    } else {
        return new ApplicationProtocolConfig(
                Protocol.ALPN,
                SelectorFailureBehavior.NO_ADVERTISE,
                SelectedListenerFailureBehavior.ACCEPT,
                ApplicationProtocolNames.HTTP_1_1);
    }
}
 
Example 2
Source File: Http2Server.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
private static SslContext configureTLS() throws CertificateException, SSLException {
    SelfSignedCertificate ssc = new SelfSignedCertificate();
    ApplicationProtocolConfig apn = new ApplicationProtocolConfig(
            Protocol.ALPN,
            // NO_ADVERTISE is currently the only mode supported by both OpenSsl and JDK providers.
            SelectorFailureBehavior.NO_ADVERTISE,
            // ACCEPT is currently the only mode supported by both OpenSsl and JDK providers.
            SelectedListenerFailureBehavior.ACCEPT,
            ApplicationProtocolNames.HTTP_2,
            ApplicationProtocolNames.HTTP_1_1);

    return SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey(), null)
                            .ciphers(CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
                            .applicationProtocolConfig(apn).build();
}
 
Example 3
Source File: SslContext.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
static ApplicationProtocolConfig toApplicationProtocolConfig(Iterable<String> nextProtocols) {
    ApplicationProtocolConfig apn;
    if (nextProtocols == null) {
        apn = ApplicationProtocolConfig.DISABLED;
    } else {
        apn = new ApplicationProtocolConfig(
                Protocol.NPN_AND_ALPN, SelectorFailureBehavior.CHOOSE_MY_LAST_PROTOCOL,
                SelectedListenerFailureBehavior.ACCEPT, nextProtocols);
    }
    return apn;
}
 
Example 4
Source File: OpenSslEngineTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
private static ApplicationProtocolConfig acceptingNegotiator(Protocol protocol,
        String... supportedProtocols) {
    return new ApplicationProtocolConfig(protocol,
            SelectorFailureBehavior.NO_ADVERTISE,
            SelectedListenerFailureBehavior.ACCEPT,
            supportedProtocols);
}
 
Example 5
Source File: SslContext.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
static ApplicationProtocolConfig toApplicationProtocolConfig(Iterable<String> nextProtocols) {
    ApplicationProtocolConfig apn;
    if (nextProtocols == null) {
        apn = ApplicationProtocolConfig.DISABLED;
    } else {
        apn = new ApplicationProtocolConfig(
                Protocol.NPN_AND_ALPN, SelectorFailureBehavior.CHOOSE_MY_LAST_PROTOCOL,
                SelectedListenerFailureBehavior.ACCEPT, nextProtocols);
    }
    return apn;
}
 
Example 6
Source File: JdkSslEngineTest.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
private static ApplicationProtocolConfig acceptingNegotiator(Protocol protocol, String... supportedProtocols) {
    return new ApplicationProtocolConfig(protocol,
            SelectorFailureBehavior.NO_ADVERTISE,
            SelectedListenerFailureBehavior.ACCEPT,
            supportedProtocols);
}