Example #1
0
 public override void SetSslCredentials(object state, string rootCertificates, KeyCertificatePair keyCertificatePair, VerifyPeerCallback verifyPeerCallback)
 {
     GrpcPreconditions.CheckState(!configured);
     configured        = true;
     nativeCredentials = GetOrCreateNativeCredentials((ChannelCredentials)state,
                                                      () => CreateNativeSslCredentials(rootCertificates, keyCertificatePair, verifyPeerCallback));
 }
Example #2
0
        public static ChannelCredentialsSafeHandle CreateNullCredentials()
        {
            var creds = new ChannelCredentialsSafeHandle();

            creds.SetHandle(IntPtr.Zero);
            return(creds);
        }
Example #3
0
 public static ChannelSafeHandle CreateSecure(ChannelCredentialsSafeHandle credentials, string target, ChannelArgsSafeHandle channelArgs)
 {
     // Increment reference count for the native gRPC environment to make sure we don't do grpc_shutdown() before destroying the server handle.
     // Doing so would make object finalizer crash if we end up abandoning the handle.
     GrpcEnvironment.GrpcNativeInit();
     return Native.grpcsharp_secure_channel_create(credentials, target, channelArgs);
 }
Example #4
0
 public static ChannelSafeHandle CreateSecure(ChannelCredentialsSafeHandle credentials, string target, ChannelArgsSafeHandle channelArgs)
 {
     // Increment reference count for the native gRPC environment to make sure we don't do grpc_shutdown() before destroying the server handle.
     // Doing so would make object finalizer crash if we end up abandoning the handle.
     GrpcEnvironment.GrpcNativeInit();
     return(Native.grpcsharp_secure_channel_create(credentials, target, channelArgs));
 }
Example #5
0
 public override void SetCompositeCredentials(object state, ChannelCredentials channelCredentials, CallCredentials callCredentials)
 {
     GrpcPreconditions.CheckState(!configured);
     configured        = true;
     nativeCredentials = GetOrCreateNativeCredentials((ChannelCredentials)state,
                                                      () => CreateNativeCompositeCredentials(channelCredentials, callCredentials));
 }
Example #6
0
 public override void SetInsecureCredentials(object state)
 {
     GrpcPreconditions.CheckState(!configured);
     // null corresponds to insecure credentials.
     configured        = true;
     nativeCredentials = null;
 }
Example #7
0
        private ChannelCredentialsSafeHandle CreateNativeSslCredentials(string rootCertificates, KeyCertificatePair keyCertificatePair, VerifyPeerCallback verifyPeerCallback)
        {
            IntPtr verifyPeerCallbackTag = IntPtr.Zero;

            if (verifyPeerCallback != null)
            {
                verifyPeerCallbackTag = new VerifyPeerCallbackRegistration(verifyPeerCallback).CallbackRegistration.Tag;
            }
            return(ChannelCredentialsSafeHandle.CreateSslCredentials(rootCertificates, keyCertificatePair, verifyPeerCallbackTag));
        }
Example #8
0
 private ChannelCredentialsSafeHandle CreateNativeCompositeCredentials(ChannelCredentials channelCredentials, CallCredentials callCredentials)
 {
     using (var callCreds = callCredentials.ToNativeCredentials())
     {
         var nativeComposite = ChannelCredentialsSafeHandle.CreateComposite(channelCredentials.ToNativeCredentials(), callCreds);
         if (nativeComposite.IsInvalid)
         {
             throw new ArgumentException("Error creating native composite credentials. Likely, this is because you are trying to compose incompatible credentials.");
         }
         return(nativeComposite);
     }
 }
Example #9
0
 internal static extern ChannelCredentialsSafeHandle grpcsharp_composite_channel_credentials_create(ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds);
Example #10
0
 ChannelSafeHandle IPlatformInvocation.grpcsharp_secure_channel_create(ChannelCredentialsSafeHandle credentials,
     string target, ChannelArgsSafeHandle channelArgs)
 {
     return grpcsharp_secure_channel_create(credentials, target, channelArgs);
 }
Example #11
0
 static extern ChannelSafeHandle grpcsharp_secure_channel_create(ChannelCredentialsSafeHandle credentials, string target, ChannelArgsSafeHandle channelArgs);
Example #12
0
 ChannelCredentialsSafeHandle IPlatformInvocation.grpcsharp_composite_channel_credentials_create(
     ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds)
 {
     return grpcsharp_composite_channel_credentials_create(channelCreds, callCreds);
 }
Example #13
0
 ChannelSafeHandle IPlatformInvocation.grpcsharp_secure_channel_create(ChannelCredentialsSafeHandle credentials,
                                                                       string target, ChannelArgsSafeHandle channelArgs)
 {
     return(grpcsharp_secure_channel_create(credentials, target, channelArgs));
 }
 public static ChannelCredentialsSafeHandle CreateNullCredentials()
 {
     var creds = new ChannelCredentialsSafeHandle();
     creds.SetHandle(IntPtr.Zero);
     return creds;
 }
Example #15
0
 internal static extern ChannelSafeHandle grpcsharp_secure_channel_create(ChannelCredentialsSafeHandle credentials, string target, ChannelArgsSafeHandle channelArgs);
 static extern ChannelCredentialsSafeHandle grpcsharp_composite_channel_credentials_create(ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds);
Example #17
0
 public static ChannelCredentialsSafeHandle CreateComposite(ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds)
 {
     return(Native.grpcsharp_composite_channel_credentials_create(channelCreds, callCreds));
 }
 public static ChannelCredentialsSafeHandle CreateComposite(ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds)
 {
     return grpcsharp_composite_channel_credentials_create(channelCreds, callCreds);
 }
Example #19
0
 ChannelCredentialsSafeHandle IPlatformInvocation.grpcsharp_composite_channel_credentials_create(
     ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds)
 {
     return(grpcsharp_composite_channel_credentials_create(channelCreds, callCreds));
 }