-
Notifications
You must be signed in to change notification settings - Fork 167
Add SSL cert validation callback #826
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2594,6 +2594,8 @@ natsOptions_SetExpectedHostname(natsOptions *opts, const char *hostname); | |
| * By default, the server certificate is verified. You can disable the verification | ||
| * by passing <c>true</c> to this function. | ||
| * | ||
| * \note Setting this to true will clear SSL verfication callback set via natsOptions_SetSSLVerificationCallback(). | ||
| * | ||
| * \warning This is fine for tests but use with caution since this is not secure. | ||
| * | ||
| * @param opts the pointer to the #natsOptions object. | ||
|
|
@@ -2602,6 +2604,21 @@ natsOptions_SetExpectedHostname(natsOptions *opts, const char *hostname); | |
| NATS_EXTERN natsStatus | ||
| natsOptions_SkipServerVerification(natsOptions *opts, bool skip); | ||
|
|
||
| typedef struct x509_store_ctx_st X509_STORE_CTX; | ||
| typedef int (*SSL_verify_cb)(int preverify_ok, X509_STORE_CTX *x509_ctx); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove those 2 lines. This would cause errors otherwise saying that you are redefining them. |
||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole function would need to be protected by the |
||
| /** \brief Sets the certificate validation callback. | ||
| * | ||
| * Sets a callback used to verify the SSL certificate. | ||
| * | ||
| * \note Setting a callback will enable SSL verification if disabled via natsOptions_SkipServerVerification(). | ||
| * | ||
| * @param opts the pointer to the #natsOptions object. | ||
| * @param callback the custom SSL verification handler to invoke. see https://docs.openssl.org/master/man3/SSL_CTX_set_verify/ | ||
| */ | ||
| NATS_EXTERN natsStatus | ||
| natsOptions_SetSSLVerificationCallback(natsOptions *opts, SSL_verify_cb callback); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This option will not show-up in the generated documentation as it stands. We would need to add to and in the main When generating docs, it will update the file |
||
| /** \brief Sets the verbose mode. | ||
| * | ||
| * Sets the verbose mode. If `true`, sends are echoed by the server with | ||
|
|
||
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.
I am not sure what the discussion you had with @levb and @mtmk was, but I think your first approach may have been a bit better with the abstraction.
This PR would not compile as-is. You would need to add at the top of this file something like:
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.
Also, in
CMakeLists.txtofexamples,examples/getstarted,examples/stanandtest/dylibdirectories, you would need to add:so that those can be built with the openssl include directory.