How to create an HTTPS request to the web services of the dcm4chee-arc server?

64 views
Skip to first unread message

Alexandr Kuznetsov

unread,
Jul 10, 2020, 2:29:09 PM7/10/20
to dcm4che
Hey.
Please tell me how you can make an HTTPS request - a request to the server’s web services. I understand that you need to use encryption keys or certificates.
Here is my code in C#:
          
try
          {
                var url = "https://dockerpacs:8443/dcm4chee-arc/aets/DOCKERPACS/rs/mwlitems"
                HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url);
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
                ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback((s, ce, ch, ssl) => true);
                WebResponse response = await request.GetResponseAsync();
                using (Stream stream = response.GetResponseStream())
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        ResponceText = reader.ReadToEnd();
                        response.Close();
                    }
                }
            }
            catch (WebException ex)
            {
                WebExceptionStatus status = ex.Status;
                if (status == WebExceptionStatus.ProtocolError)
                {
                    HttpWebResponse httpResponse = (HttpWebResponse)ex.Response;
                    textBox1.Text = ex.Message;
                    MessageBox.Show(ex.Message);
                }
                MessageBox.Show(ex.Message);
            }


If you use the HTTP request and port 8080, then everything works well.
But when using HTTPS I get an error:
The request was aborted: Could not create SSL/TLS secure channel.

Can someone show with a code example how to implement such an HTTPS request?

Thanks in advance.

Sincerely, Alexander
Reply all
Reply to author
Forward
0 new messages