views:

424

answers:

1

Hi,

It seems that I cannot get the benefit of ReceiveAsync when using SslStream since I will have to do the reading through SslStream, which only supports the Begin* End* async model.

Is it possible to just use SslStream until authentication is done, and from then on just access the socket directly? This means I would have to find out what level of security was negotiated, and then apply the correct encryption/decryption to the buffers myself. Encryption before sending, and decryption after receiving.

Is this doable?

Thanks!

+1  A: 

SslStream is giving you privacy + server auth, and depending on whether you use ClientCertificates, Client authentication as well. You cannot use the socket directly, because once the SSL session is established, the key exchange would have bound the encryption and other algorithms to the session, and it is not possible to duplicate that in code.

Anyway, SslStream.Begin/End methods give you the async functionality you need. Why do you need to fall back to Socket.SendAsync/ReceiveAsync() ?

feroze