mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-27 06:51:04 +08:00
Introduce custom TLS init function
This commit is contained in:
parent
755bf3c412
commit
f43a5a005c
@ -3780,6 +3780,9 @@ void mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) {
|
|||||||
if (tls == NULL) {
|
if (tls == NULL) {
|
||||||
mg_error(c, "TLS OOM");
|
mg_error(c, "TLS OOM");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
} else if (opts->ifn != NULL && opts->ifn(opts) != 0) {
|
||||||
|
mg_error(c, "TLS custom init failed");
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
LOG(LL_DEBUG, ("%lu Setting TLS, CA: %s, CRL: %s, cert: %s, key: %s", c->id,
|
LOG(LL_DEBUG, ("%lu Setting TLS, CA: %s, CRL: %s, cert: %s, key: %s", c->id,
|
||||||
ca, crl, cert, certkey));
|
ca, crl, cert, certkey));
|
||||||
@ -3945,6 +3948,9 @@ void mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) {
|
|||||||
if (tls == NULL) {
|
if (tls == NULL) {
|
||||||
mg_error(c, "TLS OOM");
|
mg_error(c, "TLS OOM");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
} else if (opts->ifn != NULL && opts->ifn(opts) != 0) {
|
||||||
|
mg_error(c, "TLS custom init failed");
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s_initialised) {
|
if (!s_initialised) {
|
||||||
|
@ -930,6 +930,7 @@ struct mg_tls_opts {
|
|||||||
const char *certkey; // Certificate key
|
const char *certkey; // Certificate key
|
||||||
const char *ciphers; // Cipher list
|
const char *ciphers; // Cipher list
|
||||||
struct mg_str srvname; // If not empty, enables server name verification
|
struct mg_str srvname; // If not empty, enables server name verification
|
||||||
|
int (*ifn)(struct mg_tls_opts *); // Custom init func. Return 0 on success
|
||||||
};
|
};
|
||||||
|
|
||||||
void mg_tls_init(struct mg_connection *, struct mg_tls_opts *);
|
void mg_tls_init(struct mg_connection *, struct mg_tls_opts *);
|
||||||
|
@ -11,6 +11,7 @@ struct mg_tls_opts {
|
|||||||
const char *certkey; // Certificate key
|
const char *certkey; // Certificate key
|
||||||
const char *ciphers; // Cipher list
|
const char *ciphers; // Cipher list
|
||||||
struct mg_str srvname; // If not empty, enables server name verification
|
struct mg_str srvname; // If not empty, enables server name verification
|
||||||
|
int (*ifn)(struct mg_tls_opts *); // Custom init func. Return 0 on success
|
||||||
};
|
};
|
||||||
|
|
||||||
void mg_tls_init(struct mg_connection *, struct mg_tls_opts *);
|
void mg_tls_init(struct mg_connection *, struct mg_tls_opts *);
|
||||||
|
@ -58,6 +58,9 @@ void mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) {
|
|||||||
if (tls == NULL) {
|
if (tls == NULL) {
|
||||||
mg_error(c, "TLS OOM");
|
mg_error(c, "TLS OOM");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
} else if (opts->ifn != NULL && opts->ifn(opts) != 0) {
|
||||||
|
mg_error(c, "TLS custom init failed");
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
LOG(LL_DEBUG, ("%lu Setting TLS, CA: %s, CRL: %s, cert: %s, key: %s", c->id,
|
LOG(LL_DEBUG, ("%lu Setting TLS, CA: %s, CRL: %s, cert: %s, key: %s", c->id,
|
||||||
ca, crl, cert, certkey));
|
ca, crl, cert, certkey));
|
||||||
|
@ -28,6 +28,9 @@ void mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) {
|
|||||||
if (tls == NULL) {
|
if (tls == NULL) {
|
||||||
mg_error(c, "TLS OOM");
|
mg_error(c, "TLS OOM");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
} else if (opts->ifn != NULL && opts->ifn(opts) != 0) {
|
||||||
|
mg_error(c, "TLS custom init failed");
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s_initialised) {
|
if (!s_initialised) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user