用法
tls-dh-params-file redis.dh
?
用途
設置密鑰交換協(xié)議文件
迪菲-赫爾曼密鑰交換(英語:Diffie–Hellman key exchange刻恭,縮寫為DH
)
使用DH
后TLS握手中的第三個隨機數(shù)不在網(wǎng)絡上傳輸(原來是加密傳輸)庞呕,加強了安全性。
迪菲-赫爾曼密鑰交換-原理概要
?
生成dh文件
openssl dhparam -5 -out redis.dh 2048
或
openssl dhparam -2 -out redis.dh 2048
?
注意事項:
暫無
?
redis源碼
https://github.com/redis/redis/blob/6.2.6/src
331 if (ctx_config->dh_params_file) {
332 FILE *dhfile = fopen(ctx_config->dh_params_file, "r");
333 DH *dh = NULL;
334 if (!dhfile) {
335 serverLog(LL_WARNING, "Failed to load %s: %s", ctx_config->dh_params_file, strerror(errno));
336 goto error;
337 }
338
339 dh = PEM_read_DHparams(dhfile, NULL, NULL, NULL);
340 fclose(dhfile);
341 if (!dh) {
342 serverLog(LL_WARNING, "%s: failed to read DH params.", ctx_config->dh_params_file);
343 goto error;
344 }
345
346 if (SSL_CTX_set_tmp_dh(ctx, dh) <= 0) {
347 ERR_error_string_n(ERR_get_error(), errbuf, sizeof(errbuf));
348 serverLog(LL_WARNING, "Failed to load DH params file: %s: %s", ctx_config->dh_params_file, errbuf);
349 DH_free(dh);
350 goto error;
351 }
352
353 DH_free(dh);
354 }
?
原生注釋
# Configure a DH parameters file to enable Diffie-Hellman (DH) key exchange:
#
# tls-dh-params-file redis.dh