-
Notifications
You must be signed in to change notification settings - Fork 218
Separated client init from server init, and added struct to manage custom ssl/tls protocols #157
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
Open
shehzadkhawar
wants to merge
4
commits into
sustrik:master
Choose a base branch
from
shehzadkhawar:master
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
Show all changes
4 commits
Select commit
Hold shift + click to select a range
92f28c9
Moved ssl client context init to sslconnect func
shehzadkhawar 20e91b4
Added custom ssl server method functionality e.g. SSLvXX, TLSvXX supp…
shehzadkhawar 87c131c
Added link local ipv6 address based communication handling
shehzadkhawar e6d8fb6
hard coded interface index to test
shehzadkhawar 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -67,31 +67,33 @@ static void ssl_init(void) { | |
| initialised = 1; | ||
| OpenSSL_add_all_algorithms(); | ||
| SSL_library_init(); | ||
|
|
||
| /* TODO: Move to sslconnect() */ | ||
| ssl_cli_ctx = SSL_CTX_new(SSLv23_client_method()); | ||
| mill_assert(ssl_cli_ctx); | ||
| } | ||
|
|
||
|
Owner
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 was meant more like "make the context local to the client socket", i.e. move it from global variable to the socket strucuture. |
||
| struct mill_sslsock *mill_ssllisten_(struct mill_ipaddr addr, | ||
| const char *cert_file, const char *key_file, int backlog) { | ||
| struct mill_sslsock *mill_ssllisten_(SSLSERVER_p_st server, int backlog) { | ||
| ssl_init(); | ||
| /* Load certificates. */ | ||
| SSL_CTX *ctx = SSL_CTX_new(SSLv23_server_method()); | ||
| SSL_CTX *ctx; | ||
| if(server->method != NULL){ | ||
| ctx = SSL_CTX_new((SSL_METHOD*)server->method); | ||
| } else { | ||
| ctx = SSL_CTX_new(TLSv1_2_server_method()); | ||
| } | ||
| if(!ctx) | ||
| return NULL; | ||
| if(cert_file && SSL_CTX_use_certificate_chain_file(ctx, cert_file) <= 0) | ||
| if(server->cert_file && SSL_CTX_use_certificate_chain_file(ctx, server->cert_file) <= 0) | ||
| return NULL; | ||
| if(key_file && SSL_CTX_use_PrivateKey_file(ctx, | ||
| key_file, SSL_FILETYPE_PEM) <= 0) | ||
| if(server->key_file && SSL_CTX_use_PrivateKey_file(ctx, | ||
| server->key_file, SSL_FILETYPE_PEM) <= 0) | ||
| return NULL; | ||
| /* Check for inconsistent private key. */ | ||
| if(SSL_CTX_check_private_key(ctx) <= 0) | ||
| return NULL; | ||
| /* Open the listening socket. */ | ||
| tcpsock s = tcplisten(addr, backlog); | ||
| //ipaddr laddr = iplocal((const char*)server->addr, server->port, 0); | ||
| tcpsock s = tcplisten(server->addr, backlog); | ||
| if(!s) { | ||
| /* TODO: close the context */ | ||
| printf("error was exacltly here."); | ||
| return NULL; | ||
| } | ||
| /* Create the object. */ | ||
|
|
@@ -286,10 +288,13 @@ void mill_sslflush_(struct mill_sslsock *s, int64_t deadline) { | |
| errno = 0; | ||
| } | ||
|
|
||
| struct mill_sslsock *mill_sslconnect_(struct mill_ipaddr addr, | ||
| struct mill_sslsock *mill_sslconnect_(SSLCLIENT_p_st client, | ||
| int64_t deadline) { | ||
| ssl_init(); | ||
| tcpsock sock = tcpconnect(addr, deadline); | ||
| ssl_cli_ctx = SSL_CTX_new((SSL_METHOD*)client->method); | ||
| mill_assert(ssl_cli_ctx); | ||
|
|
||
| tcpsock sock = tcpconnect(client->addr, deadline); | ||
| if(!sock) | ||
| return NULL; | ||
| struct mill_sslsock *c = ssl_conn_new(sock, ssl_cli_ctx, 1); | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
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.
Rename it to sslctx, please.