Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
9aad9229
Commit
9aad9229
authored
Sep 17, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added mg_get_ssl_context. passing fake connection to the MG_INIT_SSL event
parent
d9ab7af8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
mongoose.c
mongoose.c
+13
-8
mongoose.h
mongoose.h
+1
-0
No files found.
mongoose.c
View file @
9aad9229
...
...
@@ -526,6 +526,10 @@ int mg_get_reply_status_code(const struct mg_connection *conn) {
return
conn
==
NULL
?
-
1
:
conn
->
status_code
;
}
void
*
mg_get_ssl_context
(
const
struct
mg_connection
*
conn
)
{
return
conn
==
NULL
||
conn
->
ctx
==
NULL
?
NULL
:
conn
->
ctx
->
ssl_ctx
;
}
static
int
get_option_index
(
const
char
*
name
)
{
int
i
;
...
...
@@ -3883,17 +3887,18 @@ static int set_ssl_option(struct mg_context *ctx) {
return
0
;
}
if
(
ctx
->
user_callback
!=
NULL
)
{
ctx
->
user_callback
(
MG_INIT_SSL
,
(
struct
mg_connection
*
)
ctx
->
ssl_ctx
);
}
if
(
SSL_CTX_use_certificate_file
(
ctx
->
ssl_ctx
,
pem
,
SSL_FILETYPE_PEM
)
==
0
||
SSL_CTX_use_PrivateKey_file
(
ctx
->
ssl_ctx
,
pem
,
SSL_FILETYPE_PEM
)
==
0
)
{
// If user callback returned non-NULL, that means that user callback has
// set up certificate itself. In this case, skip sertificate setting.
if
(
call_user
(
fc
(
ctx
),
MG_INIT_SSL
)
==
NULL
&&
pem
!=
NULL
&&
(
SSL_CTX_use_certificate_file
(
ctx
->
ssl_ctx
,
pem
,
SSL_FILETYPE_PEM
)
==
0
||
SSL_CTX_use_PrivateKey_file
(
ctx
->
ssl_ctx
,
pem
,
SSL_FILETYPE_PEM
)
==
0
))
{
cry
(
fc
(
ctx
),
"%s: cannot open %s: %s"
,
__func__
,
pem
,
ssl_error
());
return
0
;
}
if
(
pem
!=
NULL
)
{
(
void
)
SSL_CTX_use_certificate_chain_file
(
ctx
->
ssl_ctx
,
pem
);
}
// Initialize locking callbacks, needed for thread safety.
// http://www.openssl.org/support/faq.html#PROG1
...
...
@@ -4445,7 +4450,7 @@ struct mg_context *mg_start(mg_callback_t user_callback, void *user_data,
// be initialized before listening ports. UID must be set last.
if
(
!
set_gpass_option
(
ctx
)
||
#if !defined(NO_SSL)
(
ctx
->
config
[
SSL_CERTIFICATE
]
!=
NULL
&&
!
set_ssl_option
(
ctx
)
)
||
!
set_ssl_option
(
ctx
)
||
#endif
!
set_ports_option
(
ctx
)
||
#if !defined(_WIN32)
...
...
mongoose.h
View file @
9aad9229
...
...
@@ -154,6 +154,7 @@ const struct mg_request_info *mg_get_request_info(const struct mg_connection *);
void
*
mg_get_user_data
(
struct
mg_connection
*
);
const
char
*
mg_get_log_message
(
const
struct
mg_connection
*
);
int
mg_get_reply_status_code
(
const
struct
mg_connection
*
);
void
*
mg_get_ssl_context
(
const
struct
mg_connection
*
);
// Send data to the client.
...
...
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