aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Core/Channel.cs
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-07-26 12:54:23 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-07-26 12:54:23 -0700
commitcbc4fb9f2e0d6971c93375e6057d1488e8b08f6d (patch)
tree1c23d8707036742bda2ec8c3534ccb6729146875 /src/csharp/Grpc.Core/Channel.cs
parente2f2e9a31a39caf56a216db0c53c74a0a52606de (diff)
parent5c575dd6e4b01cd68cca5d1917b58023dcf4ca0f (diff)
Merge github.com:grpc/grpc into warbling-wombat
Diffstat (limited to 'src/csharp/Grpc.Core/Channel.cs')
-rw-r--r--src/csharp/Grpc.Core/Channel.cs18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/csharp/Grpc.Core/Channel.cs b/src/csharp/Grpc.Core/Channel.cs
index e5c6abd2cb..18e6f2fda5 100644
--- a/src/csharp/Grpc.Core/Channel.cs
+++ b/src/csharp/Grpc.Core/Channel.cs
@@ -56,26 +56,24 @@ namespace Grpc.Core
/// Port will default to 80 for an unsecure channel and to 443 a secure channel.
/// </summary>
/// <param name="host">The DNS name of IP address of the host.</param>
- /// <param name="credentials">Optional credentials to create a secure channel.</param>
+ /// <param name="credentials">Credentials to secure the channel.</param>
/// <param name="options">Channel options.</param>
- public Channel(string host, Credentials credentials = null, IEnumerable<ChannelOption> options = null)
+ public Channel(string host, Credentials credentials, IEnumerable<ChannelOption> options = null)
{
this.environment = GrpcEnvironment.GetInstance();
this.options = options != null ? new List<ChannelOption>(options) : new List<ChannelOption>();
EnsureUserAgentChannelOption(this.options);
+ using (CredentialsSafeHandle nativeCredentials = credentials.ToNativeCredentials())
using (ChannelArgsSafeHandle nativeChannelArgs = ChannelOptions.CreateChannelArgs(this.options))
{
- if (credentials != null)
+ if (nativeCredentials != null)
{
- using (CredentialsSafeHandle nativeCredentials = credentials.ToNativeCredentials())
- {
- this.handle = ChannelSafeHandle.CreateSecure(nativeCredentials, host, nativeChannelArgs);
- }
+ this.handle = ChannelSafeHandle.CreateSecure(nativeCredentials, host, nativeChannelArgs);
}
else
{
- this.handle = ChannelSafeHandle.Create(host, nativeChannelArgs);
+ this.handle = ChannelSafeHandle.CreateInsecure(host, nativeChannelArgs);
}
}
this.target = GetOverridenTarget(host, this.options);
@@ -86,9 +84,9 @@ namespace Grpc.Core
/// </summary>
/// <param name="host">DNS name or IP address</param>
/// <param name="port">the port</param>
- /// <param name="credentials">Optional credentials to create a secure channel.</param>
+ /// <param name="credentials">Credentials to secure the channel.</param>
/// <param name="options">Channel options.</param>
- public Channel(string host, int port, Credentials credentials = null, IEnumerable<ChannelOption> options = null) :
+ public Channel(string host, int port, Credentials credentials, IEnumerable<ChannelOption> options = null) :
this(string.Format("{0}:{1}", host, port), credentials, options)
{
}