@@ -642,11 +642,21 @@ static int init_tls_dom(struct tls_domain *d)
642642 }
643643
644644 if (!d -> cert .s ) {
645- init_flags |= TLS_DOM_CERT_FILE_FL ;
646- LM_NOTICE ("no certificate for tls domain '%.*s' defined, using default '%s'\n" ,
647- d -> name .len , ZSW (d -> name .s ), tls_cert_file );
648- d -> cert .s = tls_cert_file ;
649- d -> cert .len = len (tls_cert_file );
645+ /* Client domains can operate without a certificate (RFC 8446 4.4.2.4,
646+ * RFC 5246 7.4.6) - an empty certificate message will be sent if the
647+ * server requests one. Server domains require a certificate. */
648+ if (d -> flags & DOM_FLAG_SRV ) {
649+ init_flags |= TLS_DOM_CERT_FILE_FL ;
650+ LM_NOTICE ("no certificate for tls server domain '%.*s' defined, "
651+ "using default '%s'\n" ,
652+ d -> name .len , ZSW (d -> name .s ), tls_cert_file );
653+ d -> cert .s = tls_cert_file ;
654+ d -> cert .len = len (tls_cert_file );
655+ } else {
656+ LM_INFO ("no certificate for tls client domain '%.*s', "
657+ "will not send client certificate\n" ,
658+ d -> name .len , ZSW (d -> name .s ));
659+ }
650660 }
651661
652662 if (!d -> ca .s ) {
@@ -722,6 +732,15 @@ static int init_tls_domains(struct tls_domain **dom)
722732 prev = NULL ;
723733 while (d ) {
724734 if (!d -> pkey .s ) {
735+ /* Client domains without a certificate don't need a private key */
736+ if (!d -> cert .s && (d -> flags & DOM_FLAG_CLI )) {
737+ LM_DBG ("no private key needed for tls client domain '%.*s' "
738+ "(no certificate configured)\n" ,
739+ d -> name .len , ZSW (d -> name .s ));
740+ prev = d ;
741+ d = d -> next ;
742+ continue ;
743+ }
725744 LM_NOTICE ("no private key for tls domain '%.*s' defined, using default '%s'\n" ,
726745 d -> name .len , ZSW (d -> name .s ), tls_pkey_file );
727746 d -> pkey .s = tls_pkey_file ;
0 commit comments