Skip to content

Add a utility that checks if SslProvider.JDK supports ALPN#9693

Merged
normanmaurer merged 1 commit intonetty:4.1from
idelpivnitskiy:jdk-ssl
Oct 23, 2019
Merged

Add a utility that checks if SslProvider.JDK supports ALPN#9693
normanmaurer merged 1 commit intonetty:4.1from
idelpivnitskiy:jdk-ssl

Conversation

@idelpivnitskiy
Copy link
Copy Markdown
Member

@idelpivnitskiy idelpivnitskiy commented Oct 19, 2019

Motivation:

We have a public utility OpenSsl.isAlpnSupported() that helps users to
check if ALPN is available for SslProvider.OPENSSL. However, we do not
provide a similar utility for SslProvider.JDK. Therefore, users who
configured ALPN with SslProvider.JDK will get a runtime exception at
the time when a new connection will be created.

Modifications:

  • Add public SslProvider.isAlpnSupported(SslProvider) utility method that
    returns true if the SslProvider supports ALPN;
  • Deprecate OpenSsl.isAlpnSupported();

Result:

Users can verify if their environment supports ALPN with
SslProvider.JDK upfront (at bootstrap), instead of failing with runtime
exception when a new connection will be created.

@netty-bot
Copy link
Copy Markdown

Can one of the admins verify this patch?

@normanmaurer
Copy link
Copy Markdown
Member

@idelpivnitskiy after thinking a bit more about it I wonder if we not just want to add a method like this to SslContext and so make things easier for users to discover in the first place:

public abstract class SslContext {
    ....
    public static boolean isAlpnSupported(SslProvider provider) {
        ....
    }
}

@normanmaurer
Copy link
Copy Markdown
Member

@idelpivnitskiy let me know what you think...

@idelpivnitskiy
Copy link
Copy Markdown
Member Author

idelpivnitskiy commented Oct 21, 2019

@normanmaurer agreed, discoverability will be better if we add a static method to SslContext class. However, SslContext has a lot of deprecated static methods. Not sure if we want to add a new one to this abstract class.
Alternative could be to add a similar static (or non-static) method directly to the SslProvider enum. That will help to avoid forgetting to update this method in case we add a new SslProvider and also good for discoverability, because the check is related to SslProvider.

Additional questions to discuss in this case:

  1. Should we deprecate OpenSsl.isAlpnSupported() and suggest to use a new method?
  2. Should we also add SslProvider.defaultProvider() (or SslProvider.defaultForClient()/SslProvider.defaultForServer()) and deprecate SslContext.defaultClientProvider()/SslProvider.defaultServerProvider()? That will help to remove all public static methods from SslContext in the 5.0 version.
    WDYT?

@normanmaurer
Copy link
Copy Markdown
Member

normanmaurer commented Oct 21, 2019 via email

Motivation:

We have a public utility `OpenSsl.isAlpnSupported()` that helps users to
check if ALPN is available for `SslProvider.OPENSSL`. However, we do not
provide a similar utility for `SslProvider.JDK`. Therefore, users who
configured ALPN with `SslProvider.JDK` will get a runtime exception at
the time when a new connection will be created.

Modifications:

- Add public `SslProvider.isAlpnSupported(SslProvider)` utility method
that returns `true` if the `SslProvider` supports ALPN;
- Deprecate `OpenSsl.isAlpnSupported()`;

Result:

Users can verify if their environment supports ALPN with
`SslProvider.JDK` upfront (at bootstrap), instead of failing with
runtime exception when a new connection will be created.
@idelpivnitskiy
Copy link
Copy Markdown
Member Author

idelpivnitskiy commented Oct 22, 2019

@normanmaurer pushed the fix and updated commit message/PR description.
I will submit a follow up for SslProvider.defaultProvider() (item 2 from my previous message) if that sounds good. Don't want to increase the scope of this PR.

@idelpivnitskiy idelpivnitskiy changed the title Add a utility that tells if SslProvider.JDK supports ALPN Add a utility that checks if SslProvider.JDK supports ALPN Oct 22, 2019
@normanmaurer
Copy link
Copy Markdown
Member

@netty-bot test this please

@normanmaurer normanmaurer merged commit b3fb2eb into netty:4.1 Oct 23, 2019
@normanmaurer
Copy link
Copy Markdown
Member

@idelpivnitskiy thanks a lot!

normanmaurer pushed a commit that referenced this pull request Oct 23, 2019
Motivation:

We have a public utility `OpenSsl.isAlpnSupported()` that helps users to
check if ALPN is available for `SslProvider.OPENSSL`. However, we do not
provide a similar utility for `SslProvider.JDK`. Therefore, users who
configured ALPN with `SslProvider.JDK` will get a runtime exception at
the time when a new connection will be created.

Modifications:

- Add public `SslProvider.isAlpnSupported(SslProvider)` utility method
that returns `true` if the `SslProvider` supports ALPN;
- Deprecate `OpenSsl.isAlpnSupported()`;

Result:

Users can verify if their environment supports ALPN with
`SslProvider` upfront (at bootstrap), instead of failing with
runtime exception when a new connection will be created.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants