-
Notifications
You must be signed in to change notification settings - Fork 142
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
Add callback-based custom private keys. #322
Conversation
dc8796f
to
a849681
Compare
/// - customPrivateKey: The custom private key to use with the TLS certificate. | ||
@inlinable | ||
public init<CustomKey: NIOSSLCustomPrivateKey & Hashable>(customPrivateKey: CustomKey) { | ||
self.representation = .custom(AnyNIOSSLCustomPrivateKey(customPrivateKey)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a question; would this be the entry point for any key that is created outside the context of BoringSSL's EVP_PKEY
type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup
Motivation: NIOSSL traditionally handles private keys be requiring that they can be decoded into a BoringSSL EVP_PKEY structure. This requires the key to have an in-memory representation that BoringSSL understands, and ultimately forces the bytes of the private key into memory. In many cases, however, this is either undesirable or not possible. For security reasons it is common to want to offload a private key into secure storage, such as the iPhone's Secure Enclave or a portable smart card. In other circumstances it may be useful to put the private key on an entirely different machine and have the signing operations occur over an RPC mechanism. In all of these cases it is necessary to have a programmatic interface to the private key that can be implemented in an essentially arbitrary manner. Modifications: - Defined a new protocol, `NIOSSLCustomPrivateKey`, that allows users to implement the private key operations needed for TLS. - Plumbed support for this interface through `NIOSSLPrivateKey`. - Added support for the BoringSSL interface to `SSLConnection`. Result: Custom TLS private keys backed by function calls can now be provided to NIOSSL.
a849681
to
5e6c20f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to my very untrained eye.
Motivation:
NIOSSL traditionally handles private keys be requiring that they can be
decoded into a BoringSSL EVP_PKEY structure. This requires the key to
have an in-memory representation that BoringSSL understands, and
ultimately forces the bytes of the private key into memory.
In many cases, however, this is either undesirable or not possible.
For security reasons it is common to want to offload a private key into
secure storage, such as the iPhone's Secure Enclave or a portable smart
card. In other circumstances it may be useful to put the private key on
an entirely different machine and have the signing operations occur over
an RPC mechanism.
In all of these cases it is necessary to have a programmatic interface
to the private key that can be implemented in an essentially arbitrary
manner.
Modifications:
NIOSSLCustomPrivateKey
, that allows users toimplement the private key operations needed for TLS.
NIOSSLPrivateKey
.SSLConnection
.Result:
Custom TLS private keys backed by function calls can now be provided to
NIOSSL.