0

Here is my code, which defaultly send a request with ssl varification:

WebRequest reqGET = WebRequest.Create(uri);
reqGET.Method = "GET";
WebResponse resp = reqGET.GetResponse();
Stream stream = resp.GetResponseStream();
StreamReader sr = new StreamReader(stream);
string rawResponse = sr.ReadToEnd();

I send this query through Postman program with turned off option of ssl verification and i get correct response: enter image description here

  • isn't this just "don't use an https uri"? what happens when you try? or do you mean that you want to use TLS but against an invalid server certificate? or...? – Marc Gravell May 27 '21 at 11:29
  • I send query to https uri and got error: "Failed to create SSL / TLS secure channel". – Ayubkhon Mamadov May 27 '21 at 11:38
  • I send this query through Postman program with turned off option of ssl verification and i get correct response. – Ayubkhon Mamadov May 27 '21 at 11:41
  • again: what does that mean? is the server here configured with a TLS certificate? is the certificate valid? what happens if you go to that URL in a browser? is this perhaps a TLS version difference, i.e. the client rejecting obsolete TLS versions? – Marc Gravell May 27 '21 at 11:42
  • Does this answer your question? [How to ignore the certificate check when ssl](https://stackoverflow.com/questions/12506575/how-to-ignore-the-certificate-check-when-ssl) – Karl-Johan Sjögren May 27 '21 at 11:51
  • When i go to that URL in a browser i got next error: "Unable to securely connect to this page The site might be using outdated or unreliable TLS security settings. If this persists, contact the website owner." Because client uses SSL 2.0. And my server doesn't support SSl 2.0. Therefore I am going to send request whithout ssl verification. – Ayubkhon Mamadov May 27 '21 at 11:59
  • Add following static method to beginning of your code which normally solves issue :ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; – jdweng May 27 '21 at 12:27
  • I added this method: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; But problem isn't solved yet((. – Ayubkhon Mamadov May 27 '21 at 17:59
  • it is highly unlikely your client or server uses ssl 2.0 because it is old and deprecated. you can drop the SecurityProtocolType to Ssl3 but that is it. Did you try the answers in the Link Karl-Johan offered? – rene May 27 '21 at 19:04
  • I know ssl 2.0 is old and derecated but the server uses it, unfortunately they can't change it. I try to impliment answers in the link Karl-Johan however it work for POST method but in my task request should be sent in GET method. – Ayubkhon Mamadov May 28 '21 at 10:40

0 Answers0