コード例 #1
0
 protected virtual void CompleteHandshake()
 {
     try
     {
         mRecordStream.FinaliseHandshake();
         mSplitApplicationDataRecords = !TlsUtilities.IsTlsV11(Context);
         if (!mAppDataReady)
         {
             mAppDataReady = true;
             if (mBlocking)
             {
                 mTlsStream = new TlsStream(this);
             }
         }
         if (mTlsSession != null)
         {
             if (mSessionParameters == null)
             {
                 mSessionParameters = new SessionParameters.Builder().SetCipherSuite(mSecurityParameters.CipherSuite).SetCompressionAlgorithm(mSecurityParameters.CompressionAlgorithm).SetMasterSecret(mSecurityParameters.MasterSecret)
                                      .SetPeerCertificate(mPeerCertificate)
                                      .SetPskIdentity(mSecurityParameters.PskIdentity)
                                      .SetSrpIdentity(mSecurityParameters.SrpIdentity)
                                      .SetServerExtensions(mServerExtensions)
                                      .Build();
                 mTlsSession = new TlsSessionImpl(mTlsSession.SessionID, mSessionParameters);
             }
             ContextAdmin.SetResumableSession(mTlsSession);
         }
         Peer.NotifyHandshakeComplete();
     }
     finally
     {
         CleanupHandshake();
     }
 }
コード例 #2
0
        protected virtual void CompleteHandshake()
        {
            try
            {
                /*
                 * We will now read data, until we have completed the handshake.
                 */
                while (this.mConnectionState != CS_END)
                {
                    if (this.mClosed)
                    {
                        // TODO What kind of exception/alert?
                    }

                    SafeReadRecord();
                }

                this.mRecordStream.FinaliseHandshake();

                this.mSplitApplicationDataRecords = !TlsUtilities.IsTlsV11(Context);

                /*
                 * If this was an initial handshake, we are now ready to send and receive application data.
                 */
                if (!mAppDataReady)
                {
                    this.mAppDataReady = true;

                    this.mTlsStream = new TlsStream(this);
                }

                if (this.mTlsSession != null)
                {
                    if (this.mSessionParameters == null)
                    {
                        this.mSessionParameters = new SessionParameters.Builder()
                                                  .SetCipherSuite(this.mSecurityParameters.CipherSuite)
                                                  .SetCompressionAlgorithm(this.mSecurityParameters.CompressionAlgorithm)
                                                  .SetMasterSecret(this.mSecurityParameters.MasterSecret)
                                                  .SetPeerCertificate(this.mPeerCertificate)
                                                  .SetPskIdentity(this.mSecurityParameters.PskIdentity)
                                                  .SetSrpIdentity(this.mSecurityParameters.SrpIdentity)
                                                  // TODO Consider filtering extensions that aren't relevant to resumed sessions
                                                  .SetServerExtensions(this.mServerExtensions)
                                                  .Build();

                        this.mTlsSession = new TlsSessionImpl(this.mTlsSession.SessionID, this.mSessionParameters);
                    }

                    ContextAdmin.SetResumableSession(this.mTlsSession);
                }

                Peer.NotifyHandshakeComplete();
            }
            finally
            {
                CleanupHandshake();
            }
        }