HttpWebRequest with client certificate fails

sorry for posting this question twice but the forum software seems to killed my previos posting…

I am using Visual Studio Mac (latest version) to build an iOS app and It needs to fetch data from an IIs server (version 10) with a GET request and by passing a client certificate.

Unfortunately the IIs answers with an RST packet and shows the error:
"The I/O operation has been aborted because of either a thread exit or an application request."

I know apple uses ATS (I am using iOS 10.3.3).

I guess this has something to do with the client certificate and IIS not accepting it.

Can someone point me to a differnt mono api where I can append the client cert to a GET request?

My code so far is as follows (with request.GetResponse() waiting until timeout...):

X509Certificate2Collection certificates = new X509Certificate2Collection (certificate);

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(this.uriString);
request.ClientCertificates = certificates;

request.Method = "GET";
request.ContentType = "application/json";
request.Accept = "application/json";
request.UserAgent = UserAgentString;
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version11;

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse ())
{
this.webResponse = response;
stream = response.GetResponseStream ();
}

Can that be a TLS 1.2 problem? IIs 10 not accepting cert with TLS 1.2 ?

Additional observations:

IIs (Version 10 on on Windows 2016) is configured for https (TLS 1.2). ATS is disabled as far as possible:

key NSAppTransportSecurity /key
dict
key NSAllowsArbitraryLoads /key true/

We found out that our GET request is only passed through to our binaries (our .dll) when in IIS Manager the SSL Settings for client certificate is set to "Ignore". Obviously the client certificate our binaries need internally is swallowed by IIs then. When setting "client certificate" to "Accept" the GET request is not passed through and does not reach our binaries.

Here you see in the failed request log, its always "internal server error" :failedRequest url="staubzeh.geh.ins.local:443/XXX/v1/List" siteId="1" appPoolId="ThinPrint Mobile Print" processId="5048" verb="GET" authenticationType="NOT_AVAILABLE" activityId="{800000C6-0000-F700-B63F-84710C7967BB}" failureReason="STATUS_CODE" statusCode="500" triggerStatusCode="500" timeTaken="124328" xmlns:freb="schemas.microsoft.com/win/2006/06/iis/freb"

Tagged:

Answers

  • RobertWelzRobertWelz USMember

    Why is my comment I posted several times during the last 3 days not shown? My fault or the forum software?

  • RobertWelzRobertWelz USMember

    Besides, what is the difference with this code for this working GET request and this not working GET Request (the latter is not passed through IIs v10 to our DLL):

    does work:
    public async Task RetrieveGet ()
    {
    HttpClient httpClient = new HttpClient ();
    httpClient.DefaultRequestHeaders.Accept.Clear ();
    httpClient.DefaultRequestHeaders.Accept.Add (new MediaTypeWithQualityHeaderValue ("application/json"));
    httpClient.DefaultRequestHeaders.UserAgent.Clear ();
    httpClient.DefaultRequestHeaders.UserAgent.ParseAdd (this.UserAgentString);

              try {
    
                return httpClient.GetAsync (new Uri (this.uriString)).ContinueWith (task => {
                    if (task.IsFaulted || task.IsCanceled)
                        throw new CommunicatorException ((task.Exception.InnerException is null) ?
                                                             task.Exception.Message : task.Exception.InnerException.Message,
                                                         HttpStatusCode.ServiceUnavailable);
    
                    HttpResponseMessage response = task.Result;
                    if (response.IsSuccessStatusCode) {
                        logger.Trace ("RetrieveGet...done.");
                        return response.Content.ReadAsStreamAsync ().Result;
                    } else {
                        logger.Trace ("RetrieveGet()-http get failed");
                        logger.Trace ("RetrieveGet...done.");
                        throw new CommunicatorException (response.ReasonPhrase, response.StatusCode, "");
    
                    }
                }).Result;
    
            } 
            catch (Exception ex) {
                throw new CommunicatorException ((ex.InnerException is null) ?
                    ex.Message : ex.InnerException.Message,
                HttpStatusCode.ServiceUnavailable);
            }
        }
    

    }

    Wireshark shows:
    Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=3C551483F5C54880B11256AEF79E2DDB
    Request Version: HTTP/1.1
    Host: staubzeh.geh.ins.local\r\n
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Connection: keep-alive\r\n
    Accept-Encoding: gzip, deflate\r\n
    User-Agent: Mobile%20Session%20Print/10.7.9 CFNetwork/811.5.4 Darwin/16.7.0\r\n
    \r\n

    [HTTP request 1/1]
    

    and this does not work:
    public async Task GetWebResponse ()
    {
    WebRequest request = WebRequest.Create (this.uriString);
    //((HttpWebRequest)request).ClientCertificates.Add (certificate);
    //((HttpWebRequest)request).ClientCertificates = certificates;
    ((HttpWebRequest)request).Accept = "/";
    ((HttpWebRequest)request).Headers ["Accept-Language"] = "de-de";
    ((HttpWebRequest)request).Headers ["Accept-Encoding"] = "gzip,deflate";
    ((HttpWebRequest)request).UserAgent = UserAgentString;

            request.Method = "GET";
    
            Stream stream;
            using (WebResponse response = (HttpWebResponse)(request.GetResponse ())) {
                this.webResponse = response;
    
                stream = response.GetResponseStream ();
    
                response.Close ();
            }
    
            logger.Trace ("GetWebResponse ... done.");
            return stream;
    

    }
    Wireshark shows:

    Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request Version: HTTP/1.1
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Accept-Encoding: gzip,deflate\r\n
    User-Agent: TPMobileClient/10.6.253 ( internal test release - no production use b289a9e ) (iPad4/1_10.3.3, de-DE)\r\n
    Connection: keep-alive\r\n
    Host: staubzeh.geh.ins.local\r\n
    \r\n

    [HTTP request 1/1]
    
  • RobertWelzRobertWelz USMember

    Besides, what is the difference with this code for the working a GET request and the not working GET request (request not passed through IIs v10 to our DLL):

    does work:

    HttpClient httpClient = new HttpClient ();
    
        private void Initialize ()
        {
            logger.Debug ("Initialize...");
            if (string.IsNullOrWhiteSpace (this.uriString)) {
                throw new Exception ("No uriString was provided.");
            }
            //ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
            httpClient.DefaultRequestHeaders.Accept.Clear ();
            httpClient.DefaultRequestHeaders.Accept.Add (new MediaTypeWithQualityHeaderValue ("application/json"));
            httpClient.DefaultRequestHeaders.UserAgent.Clear ();
            httpClient.DefaultRequestHeaders.UserAgent.ParseAdd (this.UserAgentString);
    
            logger.Debug ("Initialize...done.");
        }
    
    
        public async Task<Stream> RetrieveGet ()
        {
            logger.Trace ("RetrieveGet...");
    
            try {
    
                return httpClient.GetAsync (new Uri (this.uriString)).ContinueWith (task => {
                    if (task.IsFaulted || task.IsCanceled)
                        throw new CommunicatorException ((task.Exception.InnerException is null) ?
                                                             task.Exception.Message : task.Exception.InnerException.Message,
                                                         HttpStatusCode.ServiceUnavailable);
    
                    HttpResponseMessage response = task.Result;
                    if (response.IsSuccessStatusCode) {
                        logger.Trace ("RetrieveGet...done.");
                        return response.Content.ReadAsStreamAsync ().Result;
                    } else {
                        logger.Trace ("RetrieveGet()-http get failed");
                        logger.Trace ("RetrieveGet...done.");
                        throw new CommunicatorException (response.ReasonPhrase, response.StatusCode, "");
    
                    }
                }).Result;
            } 
            catch (Exception ex) {
                throw new CommunicatorException ((ex.InnerException is null) ?
                    ex.Message : ex.InnerException.Message,
                HttpStatusCode.ServiceUnavailable);
            }
        }
    

    Wireshark shows:

    Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=3C551483F5C54880B11256AEF79E2DDB
    Request Version: HTTP/1.1
    Host: staubzeh.geh.ins.local\r\n
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Connection: keep-alive\r\n
    Accept-Encoding: gzip, deflate\r\n
    User-Agent: Mobile%20Session%20Print/10.7.9 CFNetwork/811.5.4 Darwin/16.7.0\r\n
    \r\n
    [HTTP request 1/1]

    and the non-working code:

    public async Task GetWebResponse ()
    {
    // we are here xxx !!!
    logger.Trace ("GetWebResponse ...");

            //X509Certificate2Collection certificates = new X509Certificate2Collection (certificate);
    
            WebRequest request = WebRequest.Create (this.uriString);
            //((HttpWebRequest)request).ClientCertificates.Add (certificate);
            //((HttpWebRequest)request).ClientCertificates = certificates;
            ((HttpWebRequest)request).Accept = "*/*";
            ((HttpWebRequest)request).Headers ["Accept-Language"] = "de-de";
            ((HttpWebRequest)request).Headers ["Accept-Encoding"] = "gzip,deflate";
            ((HttpWebRequest)request).UserAgent = UserAgentString;
    
            request.Method = "GET";
    
    
            if (addRangeHeader) {
                ((HttpWebRequest)request).AddRange (this.range_from, this.range_to);
            }
    
            Stream stream;
            using (WebResponse response = (HttpWebResponse)(request.GetResponse ())) {
                this.webResponse = response;
    
                stream = response.GetResponseStream ();
    
                response.Close ();
            }
    
            logger.Trace ("GetWebResponse ... done.");
            return stream;
        }
    

    Wireshark shows:

    Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request Version: HTTP/1.1
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Accept-Encoding: gzip,deflate\r\n
    User-Agent: TPMobileClient/10.6.253 ( internal test release - no production use b289a9e ) (iPad4/1_10.3.3, de-DE)\r\n
    Connection: keep-alive\r\n
    Host: staubzeh.geh.ins.local\r\n
    \r\n
    [HTTP request 1/1]

  • RobertWelzRobertWelz USMember

    Besides, what is the difference with this code for this working GET request and this not working GET Request (the latter is not passed through IIs v10 to our DLL):

    does work:
    public async Task RetrieveGet ()
    {
    HttpClient httpClient = new HttpClient ();
    httpClient.DefaultRequestHeaders.Accept.Clear ();
    httpClient.DefaultRequestHeaders.Accept.Add (new MediaTypeWithQualityHeaderValue ("application/json"));
    httpClient.DefaultRequestHeaders.UserAgent.Clear ();
    httpClient.DefaultRequestHeaders.UserAgent.ParseAdd (this.UserAgentString);

              try {
    
                return httpClient.GetAsync (new Uri (this.uriString)).ContinueWith (task => {
                    if (task.IsFaulted || task.IsCanceled)
                        throw new CommunicatorException ((task.Exception.InnerException is null) ?
                                                             task.Exception.Message : task.Exception.InnerException.Message,
                                                         HttpStatusCode.ServiceUnavailable);
    
                    HttpResponseMessage response = task.Result;
                    if (response.IsSuccessStatusCode) {
                        logger.Trace ("RetrieveGet...done.");
                        return response.Content.ReadAsStreamAsync ().Result;
                    } else {
                        logger.Trace ("RetrieveGet()-http get failed");
                        logger.Trace ("RetrieveGet...done.");
                        throw new CommunicatorException (response.ReasonPhrase, response.StatusCode, "");
    
                    }
                }).Result;
    
            } 
            catch (Exception ex) {
                throw new CommunicatorException ((ex.InnerException is null) ?
                    ex.Message : ex.InnerException.Message,
                HttpStatusCode.ServiceUnavailable);
            }
        }
    

    }

    Wireshark shows:
    Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=3C551483F5C54880B11256AEF79E2DDB
    Request Version: HTTP/1.1
    Host: staubzeh.geh.ins.local\r\n
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Connection: keep-alive\r\n
    Accept-Encoding: gzip, deflate\r\n
    User-Agent: Mobile%20Session%20Print/10.7.9 CFNetwork/811.5.4 Darwin/16.7.0\r\n
    \r\n

    [HTTP request 1/1]
    

    and this does not work:
    public async Task GetWebResponse ()
    {
    WebRequest request = WebRequest.Create (this.uriString);
    //((HttpWebRequest)request).ClientCertificates.Add (certificate);
    //((HttpWebRequest)request).ClientCertificates = certificates;
    ((HttpWebRequest)request).Accept = "/";
    ((HttpWebRequest)request).Headers ["Accept-Language"] = "de-de";
    ((HttpWebRequest)request).Headers ["Accept-Encoding"] = "gzip,deflate";
    ((HttpWebRequest)request).UserAgent = UserAgentString;

            request.Method = "GET";
    
            Stream stream;
            using (WebResponse response = (HttpWebResponse)(request.GetResponse ())) {
                this.webResponse = response;
    
                stream = response.GetResponseStream ();
    
                response.Close ();
            }
    
            logger.Trace ("GetWebResponse ... done.");
            return stream;
    

    }
    Wireshark shows:

    Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request Version: HTTP/1.1
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Accept-Encoding: gzip,deflate\r\n
    User-Agent: TPMobileClient/10.6.253 ( internal test release - no production use b289a9e ) (iPad4/1_10.3.3, de-DE)\r\n
    Connection: keep-alive\r\n
    Host: staubzeh.geh.ins.local\r\n
    \r\n

    [HTTP request 1/1]
    
  • RobertWelzRobertWelz USMember

    Besides, what is the difference with this code for this working GET request and this not working GET Request (the latter is not passed through IIs v10 to our DLL):

    does work:
    `

    public async Task RetrieveGet ()
    {
    HttpClient httpClient = new HttpClient ();
    httpClient.DefaultRequestHeaders.Accept.Clear ();
    httpClient.DefaultRequestHeaders.Accept.Add (new MediaTypeWithQualityHeaderValue ("application/json"));
    httpClient.DefaultRequestHeaders.UserAgent.Clear ();
    httpClient.DefaultRequestHeaders.UserAgent.ParseAdd (this.UserAgentString);
    try {
    return httpClient.GetAsync (new Uri (this.uriString)).ContinueWith (task => {
    if (task.IsFaulted || task.IsCanceled)
    throw new CommunicatorException ((task.Exception.InnerException is null) ?
    task.Exception.Message : task.Exception.InnerException.Message,
    HttpStatusCode.ServiceUnavailable);
    HttpResponseMessage response = task.Result;
    if (response.IsSuccessStatusCode) {
    logger.Trace ("RetrieveGet...done.");
    return response.Content.ReadAsStreamAsync ().Result;
    } else {
    logger.Trace ("RetrieveGet()-http get failed");
    logger.Trace ("RetrieveGet...done.");
    throw new CommunicatorException (response.ReasonPhrase, response.StatusCode, "");
    }
    }).Result;
    }
    catch (Exception ex) {
    throw new CommunicatorException ((ex.InnerException is null) ?
    ex.Message : ex.InnerException.Message,
    HttpStatusCode.ServiceUnavailable);
    }
    }
    }`

    Wireshark shows:
    `Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=3C551483F5C54880B11256AEF79E2DDB
    Request Version: HTTP/1.1
    Host: staubzeh.geh.ins.local\r\n
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Connection: keep-alive\r\n
    Accept-Encoding: gzip, deflate\r\n
    User-Agent: Mobile%20Session%20Print/10.7.9 CFNetwork/811.5.4 Darwin/16.7.0\r\n
    \r\n

    HTTP request 1/1`
    

    and this does not work:
    public async Task GetWebResponse ()
    {
    WebRequest request = WebRequest.Create (this.uriString);
    //((HttpWebRequest)request).ClientCertificates.Add (certificate);
    //((HttpWebRequest)request).ClientCertificates = certificates;
    ((HttpWebRequest)request).Accept = "/";
    ((HttpWebRequest)request).Headers ["Accept-Language"] = "de-de";
    ((HttpWebRequest)request).Headers ["Accept-Encoding"] = "gzip,deflate";
    ((HttpWebRequest)request).UserAgent = UserAgentString;
    request.Method = "GET";
    Stream stream;
    using (WebResponse response = (HttpWebResponse)(request.GetResponse ())) {
    this.webResponse = response;
    stream = response.GetResponseStream ();
    response.Close ();
    }
    logger.Trace ("GetWebResponse ... done.");
    return stream;
    }`

    Wireshark shows:

    `Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request Version: HTTP/1.1
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Accept-Encoding: gzip,deflate\r\n
    User-Agent: TPMobileClient/10.6.253 ( internal test release - no production use b289a9e ) (iPad4/1_10.3.3, de-DE)\r\n
    Connection: keep-alive\r\n
    Host: staubzeh.geh.ins.local\r\n
    \r\n

    HTTP request 1/1` 
    
  • RobertWelzRobertWelz USMember

    Besides, what is the difference with this code for this working GET request and this not working GET Request (the latter is not passed through IIs v10 to our DLL):

    does work:
    public async Task RetrieveGet ()
    {
    HttpClient httpClient = new HttpClient ();
    httpClient.DefaultRequestHeaders.Accept.Clear ();
    httpClient.DefaultRequestHeaders.Accept.Add (new MediaTypeWithQualityHeaderValue ("application/json"));
    httpClient.DefaultRequestHeaders.UserAgent.Clear ();
    httpClient.DefaultRequestHeaders.UserAgent.ParseAdd (this.UserAgentString);

              try {
    
                return httpClient.GetAsync (new Uri (this.uriString)).ContinueWith (task => {
                    if (task.IsFaulted || task.IsCanceled)
                        throw new CommunicatorException ((task.Exception.InnerException is null) ?
                                                             task.Exception.Message : task.Exception.InnerException.Message,
                                                         HttpStatusCode.ServiceUnavailable);
    
                    HttpResponseMessage response = task.Result;
                    if (response.IsSuccessStatusCode) {
                        logger.Trace ("RetrieveGet...done.");
                        return response.Content.ReadAsStreamAsync ().Result;
                    } else {
                        logger.Trace ("RetrieveGet()-http get failed");
                        logger.Trace ("RetrieveGet...done.");
                        throw new CommunicatorException (response.ReasonPhrase, response.StatusCode, "");
    
                    }
                }).Result;
    
            } 
            catch (Exception ex) {
                throw new CommunicatorException ((ex.InnerException is null) ?
                    ex.Message : ex.InnerException.Message,
                HttpStatusCode.ServiceUnavailable);
            }
        }
    

    }

    Wireshark shows:
    Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=3C551483F5C54880B11256AEF79E2DDB
    Request Version: HTTP/1.1
    Host: staubzeh.geh.ins.local\r\n
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Connection: keep-alive\r\n
    Accept-Encoding: gzip, deflate\r\n
    User-Agent: Mobile%20Session%20Print/10.7.9 CFNetwork/811.5.4 Darwin/16.7.0\r\n
    \r\n

    [HTTP request 1/1]
    

    and this does not work:
    public async Task GetWebResponse ()
    {
    WebRequest request = WebRequest.Create (this.uriString);
    //((HttpWebRequest)request).ClientCertificates.Add (certificate);
    //((HttpWebRequest)request).ClientCertificates = certificates;
    ((HttpWebRequest)request).Accept = "/";
    ((HttpWebRequest)request).Headers ["Accept-Language"] = "de-de";
    ((HttpWebRequest)request).Headers ["Accept-Encoding"] = "gzip,deflate";
    ((HttpWebRequest)request).UserAgent = UserAgentString;

            request.Method = "GET";
    
            Stream stream;
            using (WebResponse response = (HttpWebResponse)(request.GetResponse ())) {
                this.webResponse = response;
    
                stream = response.GetResponseStream ();
    
                response.Close ();
            }
    
            logger.Trace ("GetWebResponse ... done.");
            return stream;
    

    }
    Wireshark shows:

    Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request Version: HTTP/1.1
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Accept-Encoding: gzip,deflate\r\n
    User-Agent: TPMobileClient/10.6.253 ( internal test release - no production use b289a9e ) (iPad4/1_10.3.3, de-DE)\r\n
    Connection: keep-alive\r\n
    Host: staubzeh.geh.ins.local\r\n
    \r\n

    [HTTP request 1/1]
    
  • RobertWelzRobertWelz USMember

    Besides, what is the difference with this code for this working GET request and this not working GET Request (the latter is not passed through IIs v10 to our DLL):

    does work:
    `

    public async Task RetrieveGet ()
    {
    HttpClient httpClient = new HttpClient ();
    httpClient.DefaultRequestHeaders.Accept.Clear ();
    httpClient.DefaultRequestHeaders.Accept.Add (new MediaTypeWithQualityHeaderValue ("application/json"));
    httpClient.DefaultRequestHeaders.UserAgent.Clear ();
    httpClient.DefaultRequestHeaders.UserAgent.ParseAdd (this.UserAgentString);
    try {
    return httpClient.GetAsync (new Uri (this.uriString)).ContinueWith (task => {
    if (task.IsFaulted || task.IsCanceled)
    throw new CommunicatorException ((task.Exception.InnerException is null) ?
    task.Exception.Message : task.Exception.InnerException.Message,
    HttpStatusCode.ServiceUnavailable);
    HttpResponseMessage response = task.Result;
    if (response.IsSuccessStatusCode) {
    logger.Trace ("RetrieveGet...done.");
    return response.Content.ReadAsStreamAsync ().Result;
    } else {
    logger.Trace ("RetrieveGet()-http get failed");
    logger.Trace ("RetrieveGet...done.");
    throw new CommunicatorException (response.ReasonPhrase, response.StatusCode, "");
    }
    }).Result;
    }
    catch (Exception ex) {
    throw new CommunicatorException ((ex.InnerException is null) ?
    ex.Message : ex.InnerException.Message,
    HttpStatusCode.ServiceUnavailable);
    }
    }
    }`

    Wireshark shows:
    `Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=3C551483F5C54880B11256AEF79E2DDB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=3C551483F5C54880B11256AEF79E2DDB
    Request Version: HTTP/1.1
    Host: staubzeh.geh.ins.local\r\n
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Connection: keep-alive\r\n
    Accept-Encoding: gzip, deflate\r\n
    User-Agent: Mobile%20Session%20Print/10.7.9 CFNetwork/811.5.4 Darwin/16.7.0\r\n
    \r\n

    HTTP request 1/1`
    

    and this does not work:
    public async Task GetWebResponse ()
    {
    WebRequest request = WebRequest.Create (this.uriString);
    //((HttpWebRequest)request).ClientCertificates.Add (certificate);
    //((HttpWebRequest)request).ClientCertificates = certificates;
    ((HttpWebRequest)request).Accept = "/";
    ((HttpWebRequest)request).Headers ["Accept-Language"] = "de-de";
    ((HttpWebRequest)request).Headers ["Accept-Encoding"] = "gzip,deflate";
    ((HttpWebRequest)request).UserAgent = UserAgentString;
    request.Method = "GET";
    Stream stream;
    using (WebResponse response = (HttpWebResponse)(request.GetResponse ())) {
    this.webResponse = response;
    stream = response.GetResponseStream ();
    response.Close ();
    }
    logger.Trace ("GetWebResponse ... done.");
    return stream;
    }`

    Wireshark shows:

    `Hypertext Transfer Protocol
    GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n
    [Expert Info (Chat/Sequence): GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [GET /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB HTTP/1.1\r\n]
    [Severity level: Chat]
    [Group: Sequence]
    Request Method: GET
    Request URI: /TPMobilePrint/v1/[email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Path: /TPMobilePrint/v1/certificate
    Request URI Query: [email protected]&token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request URI Query Parameter: [email protected]
    Request URI Query Parameter: token=A8BDF4FCD6074370B6B8BAC365290FCB
    Request Version: HTTP/1.1
    Accept: /\r\n
    Accept-Language: de-de\r\n
    Accept-Encoding: gzip,deflate\r\n
    User-Agent: TPMobileClient/10.6.253 ( internal test release - no production use b289a9e ) (iPad4/1_10.3.3, de-DE)\r\n
    Connection: keep-alive\r\n
    Host: staubzeh.geh.ins.local\r\n
    \r\n

    HTTP request 1/1` 
    
Sign In or Register to comment.