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

Less cert work #477

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ List<ClientAndServiceTestCase> BuildDistinct()

foreach (var clientServiceTestVersion in clientServiceTestVersions)
{
if(!clientServiceTestVersion.IsLatest()) continue;
foreach (var serviceConnectionType in serviceConnectionTypes)
{
foreach (var networkConditionTestCase in networkConditionTestCases)
{

// Slightly bad network conditions e.g. a delay of 20ms can blow out test times especially when running for 2000 iterations.
// 15 iterations seems ok.
var recommendedIterations = 15;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public class NetworkConditionTestCase
public static NetworkConditionTestCase[] All => new[]
{
NetworkConditionTestCase.NetworkConditionPerfect,
NetworkConditionTestCase.NetworkCondition20MsLatency,
NetworkConditionTestCase.NetworkCondition20MsLatencyWithLastByteArrivingLate,
//NetworkConditionTestCase.NetworkCondition20MsLatency,
//NetworkConditionTestCase.NetworkCondition20MsLatencyWithLastByteArrivingLate,
//NetworkConditionTestCase.NetworkCondition20MsLatencyWithLast2BytesArrivingLate,
//NetworkConditionTestCase.NetworkCondition20MsLatencyWithLast3BytesArrivingLate
};
Expand Down
3 changes: 2 additions & 1 deletion source/Halibut/Transport/ClientCertificateValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public ClientCertificateValidator(ServiceEndPoint endPoint)

public bool Validate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslpolicyerrors)
{
var providedCert = new X509Certificate2(certificate.Export(X509ContentType.Cert), (string)null!); // Copy the cert so that we can reference it later

var providedCert = certificate as X509Certificate2 ?? new X509Certificate2(certificate.Export(X509ContentType.Cert), (string)null!); // Copy the cert so that we can reference it later
var providedThumbprint = providedCert.Thumbprint;

if (providedThumbprint == endPoint.RemoteThumbprint)
Expand Down
6 changes: 6 additions & 0 deletions source/Halibut/Transport/SecureListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,12 @@ static string GetThumbprint(SslStream stream)
return null;
}

var cert = stream.RemoteCertificate;
if(cert is X509Certificate2 x509Certificate2)
{
return x509Certificate2.Thumbprint;
}

var thumbprint = new X509Certificate2(stream.RemoteCertificate.Export(X509ContentType.Cert), (string)null!).Thumbprint;
return thumbprint;
}
Expand Down