Skip to content

Problem using https address #2

Description

@xukangmin

I'm using https address for ReportingService. I'm hosting a http jsreport server on this address with nginx/certbot (using your suggested config)

The address works perfectly fine with PostMan. I send post request to https://xxx.xxx.xx/api/report/, it gives me 200 with PDF binary.

But when I use client in .NET.

var rs = new ReportingService("https://xxx.xxx.xx/, jsReportUser, jsReportPwd);

inHouseReport = rs.RenderByNameAsync(jsReportTemplateName, quotesData).GetAwaiter().GetResult();

It give me this error:

{StatusCode: 502, ReasonPhrase: 'Bad Gateway', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Server: nginx/1.18.0
  Server: (Ubuntu)
  Date: Fri, 20 Nov 2020 21:36:28 GMT
  Connection: keep-alive
  Content-Type: text/html
  Content-Length: 166
}}

I then try to use raw https call using .NET.

                var client = new HttpClient()
                {
                    BaseAddress = new Uri(jsReportURL)
                };


                var json = JsonSerializer.Serialize(rerpotPara);
                var data = new StringContent(json, Encoding.UTF8, "application/json");


                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", System.Convert.ToBase64String(
                        Encoding.UTF8.GetBytes(String.Format("{0}:{1}", jsReportUser, jsReportPwd))));

                responseReport = client.PostAsync("api/report", data).GetAwaiter().GetResult();

This is the response:

{StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Server: nginx/1.18.0
  Server: (Ubuntu)
  Date: Fri, 20 Nov 2020 21:39:05 GMT
  Transfer-Encoding: chunked
  Connection: keep-alive
  X-Powered-By: Express
  Access-Control-Allow-Origin: *
  Access-Control-Expose-Headers: *
  Set-Cookie: render-complete=true; Path=/
  X-XSS-Protection: 0
  Content-Type: application/pdf
  Content-Disposition: inline; filename=inhousereport-main.pdf
}}

It seems to be httpClient TLS version issue. Check here: https://stackoverflow.com/questions/22251689/make-https-call-using-httpclient

in jsreport-dotnet-client, it's using
Assembly netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51

I'm using
Assembly System.Net.Http, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

Old version of httpClient seems not supporting TLS 1.1+.

My server is using 1.2+ only.

Currently I have to use custom method, hope you can fix it soon. A simple dependency update should solve the problem.

Screenshot 2020-11-20 154225

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions