/* * Client Server * * ClientHello --------> * ServerHello * Certificate* * ServerKeyExchange* * CertificateRequest* * <-------- ServerHelloDone * Certificate* * ClientKeyExchange * CertificateVerify* * [ChangeCipherSpec] * Finished --------> * [ChangeCipherSpec] * <-------- Finished * Application Data <-------> Application Data * * Fig. 1 - Message flow for a full handshake */ internal override IAsyncResult OnBeginNegotiateHandshake(AsyncCallback callback, object state) { // Reset the context if needed if (this.context.HandshakeState != HandshakeState.None) { this.context.Clear(); } // Obtain supported cipher suites this.context.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(this.context.SecurityProtocol); // Set handshake state this.context.HandshakeState = HandshakeState.Started; // Receive Client Hello message return(this.protocol.BeginReceiveRecord(this.innerStream, callback, state)); }
public void ChangeProtocol(short protocol) { SecurityProtocolType protocolType = this.DecodeProtocolCode(protocol); if ((protocolType & this.SecurityProtocolFlags) == protocolType || (this.SecurityProtocolFlags & SecurityProtocolType.Default) == SecurityProtocolType.Default) { this.SecurityProtocol = protocolType; this.SupportedCiphers.Clear(); this.SupportedCiphers = null; this.SupportedCiphers = CipherSuiteFactory.GetSupportedCiphers(protocolType); } else { throw new TlsException(AlertDescription.ProtocolVersion, "Incorrect protocol version received from server"); } }