diff options
author | 2015-07-24 14:49:30 -0700 | |
---|---|---|
committer | 2015-07-24 15:35:24 -0700 | |
commit | a96ac058f47bb155af0e835a679d9b47a57271f9 (patch) | |
tree | 00d4c3105e95e285936b5cb8cff29828db5deeda /src/csharp/Grpc.Core/Credentials.cs | |
parent | 072e7ad1f31bafe2359eb19243196ec051a22bf0 (diff) |
make insecure channel and server explicit
Diffstat (limited to 'src/csharp/Grpc.Core/Credentials.cs')
-rw-r--r-- | src/csharp/Grpc.Core/Credentials.cs | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/csharp/Grpc.Core/Credentials.cs b/src/csharp/Grpc.Core/Credentials.cs index d2dbaaf52f..4fcac0c4c0 100644 --- a/src/csharp/Grpc.Core/Credentials.cs +++ b/src/csharp/Grpc.Core/Credentials.cs @@ -41,17 +41,40 @@ namespace Grpc.Core /// </summary> public abstract class Credentials { + static readonly Credentials InsecureInstance = new InsecureCredentialsImpl(); + + /// <summary> + /// Returns instance of credential that provides no security and + /// will result in creating an unsecure channel with no encryption whatsoever. + /// </summary> + public static Credentials Insecure + { + get + { + return InsecureInstance; + } + } + /// <summary> - /// Creates native object for the credentials. + /// Creates native object for the credentials. May return null if insecure channel + /// should be created. /// </summary> /// <returns>The native credentials.</returns> internal abstract CredentialsSafeHandle ToNativeCredentials(); + + private sealed class InsecureCredentialsImpl : Credentials + { + internal override CredentialsSafeHandle ToNativeCredentials() + { + return null; + } + } } /// <summary> /// Client-side SSL credentials. /// </summary> - public class SslCredentials : Credentials + public sealed class SslCredentials : Credentials { readonly string rootCertificates; readonly KeyCertificatePair keyCertificatePair; |