Skip to content
Snippets Groups Projects
Commit 7f5b3285 authored by Michael Lumish's avatar Michael Lumish
Browse files

Merge pull request #3926 from jtattermusch/csharp_not_ssl_cert_env

Stop using SSL_CERT_FILE env for C# interop tests
parents 82116f68 beffc779
No related branches found
No related tags found
No related merge requests found
...@@ -137,7 +137,11 @@ namespace Grpc.IntegrationTesting ...@@ -137,7 +137,11 @@ namespace Grpc.IntegrationTesting
private async Task<ChannelCredentials> CreateCredentialsAsync() private async Task<ChannelCredentials> CreateCredentialsAsync()
{ {
var credentials = options.UseTls.Value ? TestCredentials.CreateTestClientCredentials(options.UseTestCa.Value) : ChannelCredentials.Insecure; var credentials = ChannelCredentials.Insecure;
if (options.UseTls.Value)
{
credentials = options.UseTestCa.Value ? TestCredentials.CreateSslCredentials() : new SslCredentials();
}
if (options.TestCase == "jwt_token_creds") if (options.TestCase == "jwt_token_creds")
{ {
......
...@@ -59,7 +59,7 @@ namespace Grpc.IntegrationTesting ...@@ -59,7 +59,7 @@ namespace Grpc.IntegrationTesting
server = new Server server = new Server
{ {
Services = { TestService.BindService(new TestServiceImpl()) }, Services = { TestService.BindService(new TestServiceImpl()) },
Ports = { { Host, ServerPort.PickUnused, TestCredentials.CreateTestServerCredentials() } } Ports = { { Host, ServerPort.PickUnused, TestCredentials.CreateSslServerCredentials() } }
}; };
server.Start(); server.Start();
...@@ -68,7 +68,7 @@ namespace Grpc.IntegrationTesting ...@@ -68,7 +68,7 @@ namespace Grpc.IntegrationTesting
new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride) new ChannelOption(ChannelOptions.SslTargetNameOverride, TestCredentials.DefaultHostOverride)
}; };
int port = server.Ports.Single().BoundPort; int port = server.Ports.Single().BoundPort;
channel = new Channel(Host, port, TestCredentials.CreateTestClientCredentials(true), options); channel = new Channel(Host, port, TestCredentials.CreateSslCredentials(), options);
client = TestService.NewClient(channel); client = TestService.NewClient(channel);
} }
......
...@@ -102,7 +102,7 @@ namespace Grpc.IntegrationTesting ...@@ -102,7 +102,7 @@ namespace Grpc.IntegrationTesting
int port = options.Port; int port = options.Port;
if (options.UseTls.Value) if (options.UseTls.Value)
{ {
server.Ports.Add(host, port, TestCredentials.CreateTestServerCredentials()); server.Ports.Add(host, port, TestCredentials.CreateSslServerCredentials());
} }
else else
{ {
......
...@@ -51,26 +51,15 @@ namespace Grpc.IntegrationTesting ...@@ -51,26 +51,15 @@ namespace Grpc.IntegrationTesting
public const string DefaultHostOverride = "foo.test.google.fr"; public const string DefaultHostOverride = "foo.test.google.fr";
public const string ClientCertAuthorityPath = "data/ca.pem"; public const string ClientCertAuthorityPath = "data/ca.pem";
public const string ClientCertAuthorityEnvName = "SSL_CERT_FILE";
public const string ServerCertChainPath = "data/server1.pem"; public const string ServerCertChainPath = "data/server1.pem";
public const string ServerPrivateKeyPath = "data/server1.key"; public const string ServerPrivateKeyPath = "data/server1.key";
public static SslCredentials CreateTestClientCredentials(bool useTestCa) public static SslCredentials CreateSslCredentials()
{ {
string caPath = ClientCertAuthorityPath; return new SslCredentials(File.ReadAllText(ClientCertAuthorityPath));
if (!useTestCa)
{
caPath = Environment.GetEnvironmentVariable(ClientCertAuthorityEnvName);
if (string.IsNullOrEmpty(caPath))
{
throw new ArgumentException("CA path environment variable is not set.");
}
}
return new SslCredentials(File.ReadAllText(caPath));
} }
public static SslServerCredentials CreateTestServerCredentials() public static SslServerCredentials CreateSslServerCredentials()
{ {
var keyCertPair = new KeyCertificatePair( var keyCertPair = new KeyCertificatePair(
File.ReadAllText(ServerCertChainPath), File.ReadAllText(ServerCertChainPath),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment