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

Closed
opened 2025-12-29 15:20:20 +01:00 by adam · 14 comments
Owner

Originally created by @xadvfh on GitHub (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));
  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.
Originally created by @xadvfh on GitHub (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)); ``` - 2 Start server with ssl enabled -3 Navigate to https://localhost:[your-port] ### 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.
adam added the bug label 2025-12-29 15:20:20 +01:00
adam closed this issue 2025-12-29 15:20:20 +01:00
Author
Owner

@xadvfh commented on GitHub (Nov 8, 2020):

@StefH any ideas on this issue?

@xadvfh commented on GitHub (Nov 8, 2020): @StefH any ideas on this issue?
Author
Owner

@StefH commented on GitHub (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 commented on GitHub (Nov 9, 2020): @xadvfh I did test with my test-app: `WireMock.Net.Console.NETCoreApp3` And with this mapping: ``` c# 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](https://user-images.githubusercontent.com/249938/98529774-57407d80-227e-11eb-8f83-74bebc38f829.png) However I do get an error that my certificate is not valid, but that's expected: ![image](https://user-images.githubusercontent.com/249938/98529900-7f2fe100-227e-11eb-8c40-02581f527301.png)
Author
Owner

@StefH commented on GitHub (Nov 17, 2020):

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

@StefH commented on GitHub (Nov 17, 2020): Does this help you @xadvfh , or do you still have issues?
Author
Owner

@xadvfh commented on GitHub (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 commented on GitHub (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.
Author
Owner

@xadvfh commented on GitHub (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);
        }
    }
}

@xadvfh commented on GitHub (Dec 2, 2020): @StefH this is still not working for me. I made a very simple program in another solution: ```c# 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); } } } ```
Author
Owner

@StefH commented on GitHub (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

@StefH commented on GitHub (Dec 2, 2020): Instead of Thread.Sleep use: ``` c# System.Console.WriteLine("Press any key to stop the server"); System.Console.ReadKey(); server.Stop(); ``` Works fine for me: ![image](https://user-images.githubusercontent.com/249938/100925633-898e7500-34e2-11eb-850a-7ef52efefffa.png)
Author
Owner

@xadvfh commented on GitHub (Dec 2, 2020):

Still not working. What could I be doing wrong?

image

@xadvfh commented on GitHub (Dec 2, 2020): Still not working. What could I be doing wrong? ![image](https://user-images.githubusercontent.com/72147686/100926671-ce4de800-34b1-11eb-97a8-72df451e455e.png)
Author
Owner

@StefH commented on GitHub (Dec 2, 2020):

Are you using .NET Framework or .NET Core?

@StefH commented on GitHub (Dec 2, 2020): Are you using .NET Framework or .NET Core?
Author
Owner

@xadvfh commented on GitHub (Dec 2, 2020):

.NET core

@xadvfh commented on GitHub (Dec 2, 2020): .NET core
Author
Owner

@xadvfh commented on GitHub (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
@xadvfh commented on GitHub (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 ```
Author
Owner

@StefH commented on GitHub (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 = https://github.com/WireMock-Net/WireMock.Net/pull/547

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

@StefH commented on GitHub (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 = https://github.com/WireMock-Net/WireMock.Net/pull/547 Can you try version `1.3.7-ci-14243.nupkg` from MyGet (https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions).
Author
Owner

@xadvfh commented on GitHub (Dec 2, 2020):

@StefH that worked! thanks!

@xadvfh commented on GitHub (Dec 2, 2020): @StefH that worked! thanks!
Author
Owner

@StefH commented on GitHub (Dec 3, 2020):

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

@StefH commented on GitHub (Dec 3, 2020): @xadvfh -> a new official version will be released today.
Author
Owner

@xadvfh commented on GitHub (Dec 7, 2020):

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

@xadvfh commented on GitHub (Dec 7, 2020): tested and works in the official new version. thanks again.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#307