OpenSSL SSL_CTX_set_tmp_dh内存泄漏

时间:2018-11-11 09:14:56

标签: c openssl

我需要对这个示例进行一些说明,该示例取自OpenSSL文档https://www.openssl.org/docs/man1.0.2/ssl/SSL_CTX_set_tmp_dh.html

...
 SSL_CTX ctx = SSL_CTX_new();
 ...

 /* Set up ephemeral DH parameters. */
 DH *dh_2048 = NULL;
 FILE *paramfile;
 paramfile = fopen("dh_param_2048.pem", "r");
 if (paramfile) {
   dh_2048 = PEM_read_DHparams(paramfile, NULL, NULL, NULL);
   fclose(paramfile);
 } else {
   /* Error. */
 }
 if (dh_2048 == NULL) {
  /* Error. */
 }
 if (SSL_CTX_set_tmp_dh(ctx, dh_2048) != 1) {
   /* Error. */
 }
 ...

谁负责释放为DH参数分配的内存?

SSL_CTX被销毁后,或者SSL_CTX_set_tmp_dh返回错误时,我是否需要调用DH_free(dh_2048)?

0 个答案:

没有答案