Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxying with SSL Not Working in .NET Core 3.1 #524

Closed
xadvfh opened this issue Oct 16, 2020 · 14 comments
Closed

Proxying with SSL Not Working in .NET Core 3.1 #524

xadvfh opened this issue Oct 16, 2020 · 14 comments
Labels

Comments

@xadvfh
Copy link

xadvfh commented Oct 16, 2020

Describe the bug

I am trying to create a proxy with SSL enabled but keep getting the error {"status":"The header name format is invalid."}.

Expected behavior:

Proxy with ssl works.

Test to reproduce

  • 1 Create proxy with:
            WireMockServer.Given(Request.Create()
                        .UsingAnyMethod())
                        .AtPriority(100)
                .RespondWith(Response.Create()
                        .WithProxy(proxyUrl));

Other related info

  1. Proxy without SSL works
    2, I am able to proxy with ssl via the Java version of wiremock so I know it's nothing to do with the website I am proxying to.
@xadvfh xadvfh added the bug label Oct 16, 2020
@xadvfh
Copy link
Author

xadvfh commented Nov 8, 2020

@StefH any ideas on this issue?

@StefH
Copy link
Collaborator

StefH commented Nov 9, 2020

@xadvfh
I did test with my test-app: WireMock.Net.Console.NETCoreApp3

And with this mapping:

            server
                .Given(Request.Create().WithHeader("ProxyThisHttps", "true")
                    .UsingGet())
                .RespondWith(Response.Create()
                    .WithProxy("https://www.google.com")
            );

Works fine when I access my wiremock on https://localhost:9433 in postman-->
image

However I do get an error that my certificate is not valid, but that's expected:
image

@StefH
Copy link
Collaborator

StefH commented Nov 17, 2020

Does this help you @xadvfh , or do you still have issues?

@xadvfh
Copy link
Author

xadvfh commented Nov 26, 2020

my apologies @StefH I didn't get notifications for this. I will try this out sometime this weekend or early next week and get back to you.

@xadvfh
Copy link
Author

xadvfh commented Dec 2, 2020

@StefH this is still not working for me. I made a very simple program in another solution:

using System.Threading;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
using WireMock.Server;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var server = WireMockServer.Start(ssl: true, port: 10080);

            server
                .Given(Request.Create()
                    .UsingAnyMethod())
                .RespondWith(Response.Create()
                    .WithProxy("https://www.google.com"));

            // open browser and point to https://localhost:10080
            Thread.Sleep(60000);
        }
    }
}

@StefH
Copy link
Collaborator

StefH commented Dec 2, 2020

Instead of Thread.Sleep use:

System.Console.WriteLine("Press any key to stop the server");
System.Console.ReadKey();
server.Stop();

Works fine for me:
image

@xadvfh
Copy link
Author

xadvfh commented Dec 2, 2020

Still not working. What could I be doing wrong?

image

@StefH
Copy link
Collaborator

StefH commented Dec 2, 2020

Are you using .NET Framework or .NET Core?

@xadvfh
Copy link
Author

xadvfh commented Dec 2, 2020

.NET core

@xadvfh
Copy link
Author

xadvfh commented Dec 2, 2020

@StefH

$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.401
 Commit:    5b6f5e5005

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.401\

Host (useful for support):
  Version: 3.1.7
  Commit:  fcfdef8d6b

.NET Core SDKs installed:
  3.1.401 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

@StefH
Copy link
Collaborator

StefH commented Dec 2, 2020

OK Thanks for the information.
Issue is related to .NET Core 3.1, it seems that headers starting with a ":" give problems.

PR = #547

Can you try version 1.3.7-ci-14243.nupkg from MyGet (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions).

@xadvfh
Copy link
Author

xadvfh commented Dec 2, 2020

@StefH that worked! thanks!

@StefH StefH changed the title Proxying with SSL Not Working Proxying with SSL Not Working in .NET Core 3.1 Dec 3, 2020
@StefH
Copy link
Collaborator

StefH commented Dec 3, 2020

@xadvfh -> a new official version will be released today.

@StefH StefH closed this as completed Dec 3, 2020
@xadvfh
Copy link
Author

xadvfh commented Dec 7, 2020

tested and works in the official new version. thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants