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
28f30738
Commit
28f30738
authored
Sep 03, 2010
by
valenok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added -DNO_SSL_DL option
parent
0f89d437
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
7 deletions
+37
-7
mongoose.c
mongoose.c
+37
-7
No files found.
mongoose.c
View file @
28f30738
...
...
@@ -238,6 +238,30 @@ typedef struct ssl_ctx_st SSL_CTX;
#define SSL_FILETYPE_PEM 1
#define CRYPTO_LOCK 1
#if defined(NO_SSL_DL)
extern
void
SSL_free
(
SSL
*
);
extern
int
SSL_accept
(
SSL
*
);
extern
int
SSL_connect
(
SSL
*
);
extern
int
SSL_read
(
SSL
*
,
void
*
,
int
);
extern
int
SSL_write
(
SSL
*
,
const
void
*
,
int
);
extern
int
SSL_get_error
(
const
SSL
*
,
int
);
extern
int
SSL_set_fd
(
SSL
*
,
int
);
extern
SSL
*
SSL_new
(
SSL_CTX
*
);
extern
SSL_CTX
*
SSL_CTX_new
(
SSL_METHOD
*
);
extern
SSL_METHOD
*
SSLv23_server_method
(
void
);
extern
int
SSL_library_init
(
void
);
extern
void
SSL_load_error_strings
(
void
);
extern
int
SSL_CTX_use_PrivateKey_file
(
SSL_CTX
*
,
const
char
*
,
int
);
extern
int
SSL_CTX_use_certificate_file
(
SSL_CTX
*
,
const
char
*
,
int
);
extern
int
SSL_CTX_use_certificate_chain_file
(
SSL_CTX
*
,
const
char
*
,
int
);
extern
void
SSL_CTX_set_default_passwd_cb
(
SSL_CTX
*
,
mg_callback_t
);
extern
void
SSL_CTX_free
(
SSL_CTX
*
);
extern
unsigned
long
ERR_get_error
(
void
);
extern
char
*
ERR_error_string
(
unsigned
long
,
char
*
);
extern
int
CRYPTO_num_locks
(
void
);
extern
void
CRYPTO_set_locking_callback
(
void
(
*
)(
int
,
int
,
const
char
*
,
int
));
extern
void
CRYPTO_set_id_callback
(
unsigned
long
(
*
)(
void
));
#else
// Dynamically loaded SSL functionality
struct
ssl_func
{
const
char
*
name
;
// SSL function name
...
...
@@ -264,11 +288,9 @@ struct ssl_func {
#define SSL_CTX_set_default_passwd_cb(x,y) \
(
*
(
void
(
*
)(
SSL_CTX
*
,
mg_callback_t
))
ssl_sw
[
13
].
ptr
)((
x
),(
y
))
#define SSL_CTX_free(x) (* (void (*)(SSL_CTX *)) ssl_sw[14].ptr)(x)
#define ERR_get_error() (* (unsigned long (*)(void)) ssl_sw[15].ptr)()
#define ERR_error_string(x, y) (* (char * (*)(unsigned long, char *)) ssl_sw[16].ptr)((x), (y))
#define SSL_load_error_strings() (* (void (*)(void)) ssl_sw[17].ptr)()
#define SSL_load_error_strings() (* (void (*)(void)) ssl_sw[15].ptr)()
#define SSL_CTX_use_certificate_chain_file(x,y,z) \
(
*
(
int
(
*
)(
SSL_CTX
*
,
const
char
*
,
int
))
ssl_sw
[
1
8
].
ptr
)((
x
),
(
y
),
(
z
))
(
*
(
int
(
*
)(
SSL_CTX
*
,
const
char
*
,
int
))
ssl_sw
[
1
6
].
ptr
)((
x
),
(
y
),
(
z
))
#define CRYPTO_num_locks() (* (int (*)(void)) crypto_sw[0].ptr)()
#define CRYPTO_set_locking_callback(x) \
...
...
@@ -276,6 +298,9 @@ struct ssl_func {
crypto_sw
[
1
].
ptr
)(
x
)
#define CRYPTO_set_id_callback(x) \
(
*
(
void
(
*
)(
unsigned
long
(
*
)(
void
)))
crypto_sw
[
2
].
ptr
)(
x
)
#define ERR_get_error() (* (unsigned long (*)(void)) ssl_sw[3].ptr)()
#define ERR_error_string(x, y) (* (char * (*)(unsigned long, char *)) \
ssl_sw
[
4
].
ptr
)((
x
),
(
y
))
// set_ssl_option() function updates this array.
// It loads SSL library dynamically and changes NULLs to the actual addresses
...
...
@@ -297,8 +322,6 @@ static struct ssl_func ssl_sw[] = {
{
"SSL_CTX_use_certificate_file"
,
NULL
},
{
"SSL_CTX_set_default_passwd_cb"
,
NULL
},
{
"SSL_CTX_free"
,
NULL
},
{
"ERR_get_error"
,
NULL
},
{
"ERR_error_string"
,
NULL
},
{
"SSL_load_error_strings"
,
NULL
},
{
"SSL_CTX_use_certificate_chain_file"
,
NULL
},
{
NULL
,
NULL
}
...
...
@@ -309,8 +332,11 @@ static struct ssl_func crypto_sw[] = {
{
"CRYPTO_num_locks"
,
NULL
},
{
"CRYPTO_set_locking_callback"
,
NULL
},
{
"CRYPTO_set_id_callback"
,
NULL
},
{
"ERR_get_error"
,
NULL
},
{
"ERR_error_string"
,
NULL
},
{
NULL
,
NULL
}
};
#endif // NO_SSL_DL
static
const
char
*
month_names
[]
=
{
"Jan"
,
"Feb"
,
"Mar"
,
"Apr"
,
"May"
,
"Jun"
,
...
...
@@ -3400,6 +3426,7 @@ static unsigned long ssl_id_callback(void) {
return
(
unsigned
long
)
pthread_self
();
}
#if !defined(NO_SSL_DL)
static
int
load_dll
(
struct
mg_context
*
ctx
,
const
char
*
dll_name
,
struct
ssl_func
*
sw
)
{
union
{
void
*
p
;
void
(
*
fp
)(
void
);}
u
;
...
...
@@ -3421,7 +3448,7 @@ static int load_dll(struct mg_context *ctx, const char *dll_name,
u
.
p
=
dlsym
(
dll_handle
,
fp
->
name
);
#endif
/* _WIN32 */
if
(
u
.
fp
==
NULL
)
{
cry
(
fc
(
ctx
),
"%s:
cannot find %s"
,
__func__
,
fp
->
name
);
cry
(
fc
(
ctx
),
"%s:
%s: cannot find %s"
,
__func__
,
dll_name
,
fp
->
name
);
return
0
;
}
else
{
fp
->
ptr
=
u
.
fp
;
...
...
@@ -3430,6 +3457,7 @@ static int load_dll(struct mg_context *ctx, const char *dll_name,
return
1
;
}
#endif // NO_SSL_DL
// Dynamically load SSL library. Set up ctx->ssl_ctx pointer.
static
int
set_ssl_option
(
struct
mg_context
*
ctx
)
{
...
...
@@ -3442,10 +3470,12 @@ static int set_ssl_option(struct mg_context *ctx) {
return
1
;
}
#if !defined(NO_SSL_DL)
if
(
!
load_dll
(
ctx
,
SSL_LIB
,
ssl_sw
)
||
!
load_dll
(
ctx
,
CRYPTO_LIB
,
crypto_sw
))
{
return
0
;
}
#endif // NO_SSL_DL
// Initialize SSL crap
SSL_library_init
();
...
...
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