-
Notifications
You must be signed in to change notification settings - Fork 393
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
Make TLS client cert/key file optional #601
Open
smititelu
wants to merge
1
commit into
SIPp:master
Choose a base branch
from
smititelu:tls_client_cert_key
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,11 +126,41 @@ const char *SSL_error_string(int ssl_error, int orig_ret) | |
|
||
SSL* SSL_new_client() | ||
{ | ||
if (access(tls_cert_name, F_OK) == 0 && access(tls_key_name, F_OK) == 0) { | ||
if (SSL_CTX_use_certificate_file(sip_trp_ssl_ctx_client, | ||
tls_cert_name, | ||
SSL_FILETYPE_PEM) != 1) { | ||
ERROR("TLS_init_context: SSL_CTX_use_certificate_file (client) failed"); | ||
return NULL; | ||
} | ||
if (SSL_CTX_use_PrivateKey_file(sip_trp_ssl_ctx_client, | ||
tls_key_name, | ||
SSL_FILETYPE_PEM) != 1) { | ||
ERROR("TLS_init_context: SSL_CTX_use_PrivateKey_file (client) failed"); | ||
return NULL; | ||
} | ||
} | ||
|
||
return SSL_new(sip_trp_ssl_ctx_client); | ||
} | ||
|
||
SSL* SSL_new_server() | ||
{ | ||
|
||
if (SSL_CTX_use_certificate_file(sip_trp_ssl_ctx, | ||
tls_cert_name, | ||
SSL_FILETYPE_PEM) != 1) { | ||
ERROR("SSL_new_server: SSL_CTX_use_certificate_file failed"); | ||
return NULL; | ||
} | ||
|
||
if (SSL_CTX_use_PrivateKey_file(sip_trp_ssl_ctx, | ||
tls_key_name, | ||
SSL_FILETYPE_PEM) != 1) { | ||
ERROR("SSL_new_server: SSL_CTX_use_PrivateKey_file failed"); | ||
return NULL; | ||
} | ||
|
||
return SSL_new(sip_trp_ssl_ctx); | ||
} | ||
|
||
|
@@ -332,38 +362,6 @@ enum tls_init_status TLS_init_context(void) | |
passwd_call_back_routine); | ||
SSL_CTX_set_default_passwd_cb(sip_trp_ssl_ctx_client, | ||
passwd_call_back_routine); | ||
|
||
if (SSL_CTX_use_certificate_file(sip_trp_ssl_ctx, | ||
tls_cert_name, | ||
SSL_FILETYPE_PEM) != 1) { | ||
char errbuf[256] = {'\0'}; | ||
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf)); | ||
ERROR("TLS_init_context: SSL_CTX_use_certificate_file failed: %s", errbuf); | ||
return TLS_INIT_ERROR; | ||
} | ||
|
||
if (SSL_CTX_use_certificate_file(sip_trp_ssl_ctx_client, | ||
tls_cert_name, | ||
SSL_FILETYPE_PEM) != 1) { | ||
char errbuf[256] = {'\0'}; | ||
ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf)); | ||
ERROR("TLS_init_context: SSL_CTX_use_certificate_file (client) failed: %s", errbuf); | ||
return TLS_INIT_ERROR; | ||
} | ||
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. Is a client cert now optional? Or is it not possible anymore? |
||
if (SSL_CTX_use_PrivateKey_file(sip_trp_ssl_ctx, | ||
tls_key_name, | ||
SSL_FILETYPE_PEM) != 1) { | ||
ERROR("TLS_init_context: SSL_CTX_use_PrivateKey_file failed"); | ||
return TLS_INIT_ERROR; | ||
} | ||
|
||
if (SSL_CTX_use_PrivateKey_file(sip_trp_ssl_ctx_client, | ||
tls_key_name, | ||
SSL_FILETYPE_PEM) != 1) { | ||
ERROR("TLS_init_context: SSL_CTX_use_PrivateKey_file (client) failed"); | ||
return TLS_INIT_ERROR; | ||
} | ||
|
||
return TLS_INIT_NORMAL; | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For indentation all the way to the right, please indent exactly to after the
(
, like above.