I am trying to write/read to sslstream on 443 port.
I can able write data to that sslstream but while reading from that sslstream, it is waiting to read, forever.
Sample code:
var add= "IPGoesHere";
var port = 443;
var remoteIpAdd= IPaddress.
Parse("IPGoesHere");
var socket = new Socket(remoteIpAdd.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
socket.Connect(new IPEndPoint(remoteIpAdd,port));
var netstream = new NetworkStream(
socket);
var sslstream = new SslStream(
netstream, false, callback1,
callback2);
sslstream.AuthenticateAsClient
(add,null, SslProtocols.Tls12, false);
var bytes = Encoding.Ascii.GetBytes("something");
sslstream.write( bytes,0,bytes.Length);
sslstream.Flush();
sslstream.Read(new byte[9],0,9); //Here it is waiting indefinitely..
Callback1 is a RemoteCertificateValidationCallback method and I am returning true here.
Callback2 is a Local certificate selection callback method and returning null here.
I am thinking like, how it can not able to read when it can able to write.
Could someone share some input on this issue.
PS: I typed entire code in mobile app. Regret for alignment.