Skip to content

OpenSslSession: Add support to defensively check for peer certs #14641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 13, 2025

Conversation

daschl
Copy link
Member

@daschl daschl commented Jan 7, 2025

Motivation

In a use-case where an application wants to check if a peer certificate has been provided without throwing an exception if none are found (as is currently the behavior when calling SSLSession#getPeerCertificates) there is currently no API available to do that.

The use-case which prompted this addition is to defensively check if a mTLS connection has been established with access to the SSLSession.

Modifications

This changeset introduces a new API to the OpenSslSession which allows to check if peer certs are available (hasPeerCertificates) and returns true if this is the case.

Result

It is now possible to check if mTLS is enabled (through checking if peer certs are presented) without throwing an exception if not.

Motivation
----------
In a use-case where an application wants to check if a peer certificate
has been provided without throwing an exception if none are found
(as is currently the behavior when calling SSLSession#getPeerCertificates)
there is currently no API available to do that.

The use-case which prompted this addition is to defensively check if
a mTLS connection has been established with access to the SSLSession.

Modifications
-------------
This changeset introduces a new API to the OpenSslSession which allows
to check if peer certs are available (hasPeerCertificates) and returns
true if this is the case.

Result
------
It is now possible to check if mTLS is enabled (through checking if
peer certs are presented) without throwing an exception if not.
@normanmaurer
Copy link
Member

@daschl I am not against this change but I wonder how this will be useful for anyone except for netty itself ? The OpenSslSession interface is package-private and so this can't be called from anyone else

@normanmaurer
Copy link
Member

@daschl @chrisvest @idelpivnitskiy PTAL again...

Copy link
Member Author

@daschl daschl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one minor comment, otherwise LGTM

@normanmaurer normanmaurer added this to the 4.1.117.Final milestone Jan 10, 2025
@normanmaurer normanmaurer merged commit d5bad42 into netty:4.1 Jan 13, 2025
15 checks passed
normanmaurer added a commit that referenced this pull request Jan 13, 2025
Motivation
----------
In a use-case where an application wants to check if a peer certificate
has been provided without throwing an exception if none are found (as is
currently the behavior when calling SSLSession#getPeerCertificates)
there is currently no API available to do that.

The use-case which prompted this addition is to defensively check if a
mTLS connection has been established with access to the SSLSession.

Modifications
-------------
This changeset introduces a new API to the OpenSslSession which allows
to check if peer certs are available (hasPeerCertificates) and returns
true if this is the case.

Result
------
It is now possible to check if mTLS is enabled (through checking if peer
certs are presented) without throwing an exception if not.

---------

Co-authored-by: Norman Maurer <[email protected]>
normanmaurer added a commit that referenced this pull request Jan 13, 2025
…) (#14653)

Motivation
----------
In a use-case where an application wants to check if a peer certificate
has been provided without throwing an exception if none are found (as is
currently the behavior when calling SSLSession#getPeerCertificates)
there is currently no API available to do that.

The use-case which prompted this addition is to defensively check if a
mTLS connection has been established with access to the SSLSession.

Modifications
-------------
This changeset introduces a new API to the OpenSslSession which allows
to check if peer certs are available (hasPeerCertificates) and returns
true if this is the case.

Result
------
It is now possible to check if mTLS is enabled (through checking if peer
certs are presented) without throwing an exception if not.

Co-authored-by: Michael Nitschinger <[email protected]>
normanmaurer added a commit that referenced this pull request Jan 13, 2025
…) (#14653)

Motivation
----------
In a use-case where an application wants to check if a peer certificate
has been provided without throwing an exception if none are found (as is
currently the behavior when calling SSLSession#getPeerCertificates)
there is currently no API available to do that.

The use-case which prompted this addition is to defensively check if a
mTLS connection has been established with access to the SSLSession.

Modifications
-------------
This changeset introduces a new API to the OpenSslSession which allows
to check if peer certs are available (hasPeerCertificates) and returns
true if this is the case.

Result
------
It is now possible to check if mTLS is enabled (through checking if peer
certs are presented) without throwing an exception if not.

Co-authored-by: Michael Nitschinger <[email protected]>
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.

4 participants