Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit b0d2cd2

Browse files
committed
#529 let generic certificate override in transparent endpoint
1 parent 315d3e2 commit b0d2cd2

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/Titanium.Web.Proxy/Models/ExplicitProxyEndPoint.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ public ExplicitProxyEndPoint(IPAddress ipAddress, int port, bool decryptSsl = tr
2727

2828
internal bool IsSystemHttpsProxy { get; set; }
2929

30-
/// <summary>
31-
/// Generic certificate to use for SSL decryption.
32-
/// </summary>
33-
public X509Certificate2 GenericCertificate { get; set; }
34-
3530
/// <summary>
3631
/// Intercept tunnel connect request.
3732
/// Valid only for explicit endpoints.

src/Titanium.Web.Proxy/Models/ProxyEndPoint.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Net;
22
using System.Net.Sockets;
3+
using System.Security.Cryptography.X509Certificates;
34

45
namespace Titanium.Web.Proxy.Models
56
{
@@ -47,5 +48,11 @@ protected ProxyEndPoint(IPAddress ipAddress, int port, bool decryptSsl)
4748
public bool IpV6Enabled => Equals(IpAddress, IPAddress.IPv6Any)
4849
|| Equals(IpAddress, IPAddress.IPv6Loopback)
4950
|| Equals(IpAddress, IPAddress.IPv6None);
51+
52+
53+
/// <summary>
54+
/// Generic certificate to use for SSL decryption.
55+
/// </summary>
56+
public X509Certificate2 GenericCertificate { get; set; }
5057
}
5158
}

src/Titanium.Web.Proxy/TransparentClientHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ private async Task handleClient(TransparentProxyEndPoint endPoint, TcpClientConn
8181
sslStream = new SslStream(clientStream);
8282

8383
string certName = HttpHelper.GetWildCardDomainName(httpsHostName);
84-
var certificate = await CertificateManager.CreateCertificateAsync(certName);
84+
var certificate = endPoint.GenericCertificate ??
85+
await CertificateManager.CreateCertificateAsync(certName);
8586

8687
// Successfully managed to authenticate the client using the fake certificate
8788
await sslStream.AuthenticateAsServerAsync(certificate, false, SslProtocols.Tls, false);

0 commit comments

Comments
 (0)