Insecure mode for https forwarding (#79)
This commit is contained in:
Родитель
3ffabee941
Коммит
89b5018407
|
@ -385,6 +385,7 @@ used on the same entry. For multiple bindings they can be used to form a list.
|
||||||
* **HostPort** - TCP port on the host to forward to
|
* **HostPort** - TCP port on the host to forward to
|
||||||
* **PortName** - Logical port name
|
* **PortName** - Logical port name
|
||||||
* **LocalSocket** - named UNIX socket forward to
|
* **LocalSocket** - named UNIX socket forward to
|
||||||
|
* **Insecure** - ignores certificate validation errors for https forwarding
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,13 @@
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Insecure
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
public string Path
|
public string Path
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
|
|
|
@ -109,7 +109,7 @@ namespace Microsoft.Azure.Relay.Bridge
|
||||||
if (binding.Http)
|
if (binding.Http)
|
||||||
{
|
{
|
||||||
var tcpRemoteForwarder =
|
var tcpRemoteForwarder =
|
||||||
new TcpRemoteForwarder(this.config, remoteForward.RelayName, binding.PortName, binding.Host, binding.HostPort, binding.Path, binding.Http);
|
new TcpRemoteForwarder(this.config, remoteForward.RelayName, binding.PortName, binding.Host, binding.HostPort, binding.Path, binding.Http, binding.Insecure);
|
||||||
remoteForwarders.Add(tcpRemoteForwarder.PortName, tcpRemoteForwarder);
|
remoteForwarders.Add(tcpRemoteForwarder.PortName, tcpRemoteForwarder);
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(binding.LocalSocket))
|
else if (!string.IsNullOrEmpty(binding.LocalSocket))
|
||||||
|
@ -127,7 +127,7 @@ namespace Microsoft.Azure.Relay.Bridge
|
||||||
else if (binding.HostPort > 0)
|
else if (binding.HostPort > 0)
|
||||||
{
|
{
|
||||||
var tcpRemoteForwarder =
|
var tcpRemoteForwarder =
|
||||||
new TcpRemoteForwarder(this.config, remoteForward.RelayName, binding.PortName, binding.Host, binding.HostPort, binding.Path, binding.Http);
|
new TcpRemoteForwarder(this.config, remoteForward.RelayName, binding.PortName, binding.Host, binding.HostPort, binding.Path, binding.Http, binding.Insecure);
|
||||||
remoteForwarders.Add(tcpRemoteForwarder.PortName, tcpRemoteForwarder);
|
remoteForwarders.Add(tcpRemoteForwarder.PortName, tcpRemoteForwarder);
|
||||||
}
|
}
|
||||||
else if (binding.HostPort < 0)
|
else if (binding.HostPort < 0)
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace Microsoft.Azure.Relay.Bridge
|
||||||
private HttpClient httpClient;
|
private HttpClient httpClient;
|
||||||
private string relaySubpath;
|
private string relaySubpath;
|
||||||
|
|
||||||
internal TcpRemoteForwarder(Config config, string relayName, string portName, string targetServer, int targetPort, string targetPath, bool http)
|
internal TcpRemoteForwarder(Config config, string relayName, string portName, string targetServer, int targetPort, string targetPath, bool http, bool insecure)
|
||||||
{
|
{
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.PortName = portName;
|
this.PortName = portName;
|
||||||
|
@ -38,7 +38,12 @@ namespace Microsoft.Azure.Relay.Bridge
|
||||||
|
|
||||||
if ( http )
|
if ( http )
|
||||||
{
|
{
|
||||||
this.httpClient = new HttpClient();
|
var httpHandler = new HttpClientHandler();
|
||||||
|
if ( insecure )
|
||||||
|
{
|
||||||
|
httpHandler.ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
|
||||||
|
}
|
||||||
|
this.httpClient = new HttpClient(httpHandler);
|
||||||
this.httpClient.BaseAddress = new UriBuilder(portName, targetServer, targetPort, targetPath).Uri;
|
this.httpClient.BaseAddress = new UriBuilder(portName, targetServer, targetPort, targetPath).Uri;
|
||||||
this.httpClient.DefaultRequestHeaders.ExpectContinue = false;
|
this.httpClient.DefaultRequestHeaders.ExpectContinue = false;
|
||||||
this.relaySubpath = "/" + relayName;
|
this.relaySubpath = "/" + relayName;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче