[sr-dev] [kamailio/kamailio] Expose the domain in certificate validation errors (#2873)

Daniel-Constantin Mierla notifications at github.com
Fri Oct 8 21:38:02 CEST 2021


@miconda commented on this pull request.



> @@ -39,7 +39,11 @@ static inline int tls_err_ret(char *s, tls_domains_cfg_t **tls_domains_cfg) {
 	{
 		while((err = ERR_get_error())) {
 			ret = 1;
-			ERR("%s%s\n", s ? s : "", ERR_error_string(err, 0));
+			char *errbuf = (char*)malloc(sizeof(char)*((*tls_domains_cfg)->srv_default->server_name.len+1));
+			memcpy(errbuf, (*tls_domains_cfg)->srv_default->server_name.s, (*tls_domains_cfg)->srv_default->server_name.len);
+			errbuf[(*tls_domains_cfg)->srv_default->server_name.len] = '\0';
+			ERR("%s%s -> %s -> verify_client is:%d\n", s ? s : "", ERR_error_string(err, 0), errbuf, (*tls_domains_cfg)->srv_default->verify_client);
+			free(errbuf);

There is no need to allocate memory and copy to it a 0-terminated string from `(*tls_domains_cfg)->srv_default->server_name`, you can use `%.*s` instead of `%s` and provide first the length and then the pointer. Should be plenty of examples in Kamailio code.

Then, because the patch is to tls module, the commit message has to be prefixed with `tls: ` -- see contributing guidelines:

  * https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md#commit-message-format

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/2873#pullrequestreview-775351904
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20211008/47d6a2ca/attachment.htm>


More information about the sr-dev mailing list