File 0002-auth-Fail-authentication-if-certificate-username-was.patch of Package dovecot23.10955

From 1a6d921b831af5228e8ad493a88bc46bdb30ca4b Mon Sep 17 00:00:00 2001
From: Aki Tuomi <aki.tuomi@open-xchange.com>
Date: Wed, 16 Jan 2019 18:24:20 +0200
Subject: [PATCH 2/3] auth: Fail authentication if certificate username was
 unexpectedly missing

---
 src/auth/auth-request-handler.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/auth/auth-request-handler.c b/src/auth/auth-request-handler.c
index ae7b458c9..318f15031 100644
--- a/src/auth/auth-request-handler.c
+++ b/src/auth/auth-request-handler.c
@@ -581,6 +581,14 @@ bool auth_request_handler_auth_begin(struct auth_request_handler *handler,
 		return TRUE;
 	}
 
+	 if (request->set->ssl_require_client_cert &&
+	     request->set->ssl_username_from_cert &&
+	     !request->cert_username) {
+		  auth_request_handler_auth_fail(handler, request,
+			 "SSL certificate didn't contain username");
+		 return TRUE;
+	 }
+
 	/* Handle initial respose */
 	if (initial_resp == NULL) {
 		/* No initial response */
-- 
2.11.0