-
Notifications
You must be signed in to change notification settings - Fork 23
Extend TLS Option #233
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
Extend TLS Option #233
Conversation
waahm7
left a comment
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.
Fix & Ship.
| /// Initializes TlsContextOptions for mutual TLS (mTLS), with client certificate and private key. These are in memory | ||
| /// buffers. These buffers must be in the PEM format. | ||
| /// | ||
| /// NOTE: This is unsupported on iOS. |
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.
debatable: You can use the @available(iOS, unavailable) declaration so that it fails at compile time. However, that will probably require consumers to do an if else to call this API.
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.
Thinking about it, it's better to set restrictions early on instead of adding them later. I added the available here for the path and data API.
@available(iOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
public static func makeMTLS(
certificateData: String,
privateKeyData: String) throws -> TLSContextOptions {
try TLSContextOptions(certificateData: certificateData, privateKeyData: privateKeyData)
}
For the pkcs12 one, it seems that @available only works for Apple platforms, we dont have a way to disable the API for linux/windows. I will leave it there for now.
| path: String, | ||
| /// Initializes TlsContextOptions for mutual TLS (mTLS), with client certificate and private key in the PKCS#12 format. | ||
| /// | ||
| /// NOTE: This only works on Apple devices. |
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.
@available directive?
Pros:
- Compile time safety instead of runtime error
Cons:
- Consumers of this API will have to do IF/ELSE at compile time, although they should probably do that anyhow if it is a cross-platform application.
|
The changes are brought in new PR: #246 |
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.