summary refs log tree commit diff
path: root/crypto/src/tls/DtlsClientProtocol.cs
diff options
context:
space:
mode:
authorPeter Dettman <peter.dettman@bouncycastle.org>2021-10-04 18:18:43 +0700
committerPeter Dettman <peter.dettman@bouncycastle.org>2021-10-04 18:18:43 +0700
commit2d280660f30fe7653ebdc5d1e3d991e20c8bc92f (patch)
treef5e24398c52a45304e2d9d0ef7ceab492ab1d471 /crypto/src/tls/DtlsClientProtocol.cs
parentFix test namespaces (diff)
downloadBouncyCastle.NET-ed25519-2d280660f30fe7653ebdc5d1e3d991e20c8bc92f.tar.xz
Fixes for new_session_ticket
- see https://github.com/bcgit/bc-csharp/issues/317
Diffstat (limited to 'crypto/src/tls/DtlsClientProtocol.cs')
-rw-r--r--crypto/src/tls/DtlsClientProtocol.cs13
1 files changed, 9 insertions, 4 deletions
diff --git a/crypto/src/tls/DtlsClientProtocol.cs b/crypto/src/tls/DtlsClientProtocol.cs
index a4810b983..44f574e3a 100644
--- a/crypto/src/tls/DtlsClientProtocol.cs
+++ b/crypto/src/tls/DtlsClientProtocol.cs
@@ -177,10 +177,7 @@ namespace Org.BouncyCastle.Tls
             }
 
             InvalidateSession(state);
-
             state.tlsSession = TlsUtilities.ImportSession(securityParameters.SessionID, null);
-            state.sessionParameters = null;
-            state.sessionMasterSecret = null;
 
             serverMessage = handshake.ReceiveMessage();
 
@@ -343,6 +340,14 @@ namespace Org.BouncyCastle.Tls
                 serverMessage = handshake.ReceiveMessage();
                 if (serverMessage.Type == HandshakeType.new_session_ticket)
                 {
+                    /*
+                     * RFC 5077 3.4. If the client receives a session ticket from the server, then it
+                     * discards any Session ID that was sent in the ServerHello.
+                     */
+                    securityParameters.m_sessionID = TlsUtilities.EmptyBytes;
+                    InvalidateSession(state);
+                    state.tlsSession = TlsUtilities.ImportSession(securityParameters.SessionID, null);
+
                     ProcessNewSessionTicket(state, serverMessage.Body);
                 }
                 else
@@ -373,7 +378,7 @@ namespace Org.BouncyCastle.Tls
                 .SetServerExtensions(state.serverExtensions)
                 .Build();
 
-            state.tlsSession = TlsUtilities.ImportSession(state.tlsSession.SessionID, state.sessionParameters);
+            state.tlsSession = TlsUtilities.ImportSession(securityParameters.SessionID, state.sessionParameters);
 
             securityParameters.m_tlsUnique = securityParameters.LocalVerifyData;