mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-25 20:28:27 +00:00
Use SSL_CTX_{get,set}_app_data to store context
h/t @hendrikw01 Fixes https://github.com/cesanta/mongoose/issues/826 Closes https://github.com/cesanta/mongoose/pull/831 PUBLISHED_FROM=d5e1285bee9bcbb85d581ee62972a2fde7d9c0db
This commit is contained in:
1 parent
3e59e1c465
commit
5a0b6fc35a
1 file changed
+2
-3
+2
-3
@@ -4407,7 +4407,7 @@ static unsigned int mg_ssl_if_ossl_psk_cb(SSL *ssl, const char *hint,
|
|||||||
unsigned char *psk,
|
unsigned char *psk,
|
||||||
unsigned int max_psk_len) {
|
unsigned int max_psk_len) {
|
||||||
struct mg_ssl_if_ctx *ctx =
|
struct mg_ssl_if_ctx *ctx =
|
||||||
(struct mg_ssl_if_ctx *) ssl->ctx->msg_callback_arg;
|
(struct mg_ssl_if_ctx *) SSL_CTX_get_app_data(SSL_get_SSL_CTX(ssl));
|
||||||
size_t key_len = ctx->psk.len - ctx->identity_len - 1;
|
size_t key_len = ctx->psk.len - ctx->identity_len - 1;
|
||||||
DBG(("hint: '%s'", (hint ? hint : "")));
|
DBG(("hint: '%s'", (hint ? hint : "")));
|
||||||
if (ctx->identity_len + 1 > max_identity_len) {
|
if (ctx->identity_len + 1 > max_identity_len) {
|
||||||
@@ -4456,8 +4456,7 @@ static enum mg_ssl_if_result mg_ssl_if_ossl_set_psk(struct mg_ssl_if_ctx *ctx,
|
|||||||
mbuf_append(&ctx->psk, identity, ctx->identity_len + 1);
|
mbuf_append(&ctx->psk, identity, ctx->identity_len + 1);
|
||||||
mbuf_append(&ctx->psk, key, key_len);
|
mbuf_append(&ctx->psk, key, key_len);
|
||||||
SSL_CTX_set_psk_client_callback(ctx->ssl_ctx, mg_ssl_if_ossl_psk_cb);
|
SSL_CTX_set_psk_client_callback(ctx->ssl_ctx, mg_ssl_if_ossl_psk_cb);
|
||||||
/* Hack: there is no field for us to keep this, so we use msg_callback_arg */
|
SSL_CTX_set_app_data(ctx->ssl_ctx, ctx);
|
||||||
ctx->ssl_ctx->msg_callback_arg = ctx;
|
|
||||||
return MG_SSL_OK;
|
return MG_SSL_OK;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in new issue
Block a user