Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
mongoose
Commits
ca11f5ab
Commit
ca11f5ab
authored
Apr 29, 2020
by
Sergey Lyubka
Committed by
Cesanta Bot
May 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix OpenSSL error issue
PUBLISHED_FROM=a3bcdb68f48a4de4a4f55b4399792fdd5211c88d
parent
000d24d3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
mongoose.c
mongoose.c
+12
-0
mg_ssl_if_openssl.c
src/mg_ssl_if_openssl.c
+12
-0
No files found.
mongoose.c
View file @
ca11f5ab
...
...
@@ -4469,6 +4469,7 @@ struct mg_iface *mg_socks_mk_iface(struct mg_mgr *mgr, const char *proxy_addr) {
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#ifndef KR_VERSION
#include <openssl/tls1.h>
#endif
...
...
@@ -4591,6 +4592,17 @@ static enum mg_ssl_if_result mg_ssl_if_ssl_err(struct mg_connection *nc,
int
res
)
{
struct
mg_ssl_if_ctx
*
ctx
=
(
struct
mg_ssl_if_ctx
*
)
nc
->
ssl_if_data
;
int
err
=
SSL_get_error
(
ctx
->
ssl
,
res
);
/*
* We've just fetched the last error from the queue.
* Now we need to clear the error queue. If we do not, then the following
* can happen (actually reported):
* - A new connection is accept()-ed with cert error (e.g. self-signed cert)
* - Since all accept()-ed connections share listener's context,
* - *ALL* SSL accepted connection report read error on the next poll cycle.
* Thus a single errored connection can close all the rest, unrelated ones.
* Clearing the error keeps the shared SSL_CTX in an OK state.
*/
ERR_clear_error
();
if
(
err
==
SSL_ERROR_WANT_READ
)
return
MG_SSL_WANT_READ
;
if
(
err
==
SSL_ERROR_WANT_WRITE
)
return
MG_SSL_WANT_WRITE
;
DBG
((
"%p %p SSL error: %d %d"
,
nc
,
ctx
->
ssl_ctx
,
res
,
err
));
...
...
src/mg_ssl_if_openssl.c
View file @
ca11f5ab
...
...
@@ -10,6 +10,7 @@
#endif
#include <openssl/ssl.h>
#include <openssl/err.h>
#ifndef KR_VERSION
#include <openssl/tls1.h>
#endif
...
...
@@ -132,6 +133,17 @@ static enum mg_ssl_if_result mg_ssl_if_ssl_err(struct mg_connection *nc,
int
res
)
{
struct
mg_ssl_if_ctx
*
ctx
=
(
struct
mg_ssl_if_ctx
*
)
nc
->
ssl_if_data
;
int
err
=
SSL_get_error
(
ctx
->
ssl
,
res
);
/*
* We've just fetched the last error from the queue.
* Now we need to clear the error queue. If we do not, then the following
* can happen (actually reported):
* - A new connection is accept()-ed with cert error (e.g. self-signed cert)
* - Since all accept()-ed connections share listener's context,
* - *ALL* SSL accepted connection report read error on the next poll cycle.
* Thus a single errored connection can close all the rest, unrelated ones.
* Clearing the error keeps the shared SSL_CTX in an OK state.
*/
ERR_clear_error
();
if
(
err
==
SSL_ERROR_WANT_READ
)
return
MG_SSL_WANT_READ
;
if
(
err
==
SSL_ERROR_WANT_WRITE
)
return
MG_SSL_WANT_WRITE
;
DBG
((
"%p %p SSL error: %d %d"
,
nc
,
ctx
->
ssl_ctx
,
res
,
err
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment