Skip to content

Commit 999d678

Browse files
authored
Merge pull request #1019 from Unity-Technologies/unity-master-fix-server-clientauth-error-on-no-certificate
UnityTls server no longer throws an exception if there is no client cert during client authentication
2 parents e452eea + 28e179a commit 999d678

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

mcs/class/System/Mono.UnityTls/UnityTlsContext.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,18 +304,17 @@ public override bool ProcessHandshake ()
304304
if (lastException != null)
305305
throw lastException;
306306

307-
// Not done is not an error if we are server and don't ask for ClientCertificate
308-
if (result == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE && IsServer && !AskForClientCertificate)
307+
// Not done is only an error if we are a client. Even servers with AskForClientCertificate should ignore it since .Net client authentification is always optional.
308+
if (IsServer && result == UnityTls.unitytls_x509verify_result.UNITYTLS_X509VERIFY_NOT_DONE) {
309309
Unity.Debug.CheckAndThrow (errorState, "Handshake failed", AlertDescription.HandshakeFailure);
310-
else
311-
Unity.Debug.CheckAndThrow (errorState, result, "Handshake failed", AlertDescription.HandshakeFailure);
312-
313-
// .Net implementation gives the server a verification callback (with null cert) even if AskForClientCertificate is false.
314-
// We stick to this behavior here.
315-
if (IsServer && !AskForClientCertificate) {
310+
311+
// .Net implementation gives the server a verification callback (with null cert) even if AskForClientCertificate is false.
312+
// We stick to this behavior here.
316313
if (!ValidateCertificate (null, null))
317314
throw new TlsException (AlertDescription.HandshakeFailure, "Verification failure during handshake");
318315
}
316+
else
317+
Unity.Debug.CheckAndThrow (errorState, result, "Handshake failed", AlertDescription.HandshakeFailure);
319318

320319
return true;
321320
}

0 commit comments

Comments
 (0)