Index: third_party/grpc/src/csharp/Grpc.Core/Internal/ServerCredentialsSafeHandle.cs |
diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs b/third_party/grpc/src/csharp/Grpc.Core/Internal/ServerCredentialsSafeHandle.cs |
similarity index 55% |
copy from third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs |
copy to third_party/grpc/src/csharp/Grpc.Core/Internal/ServerCredentialsSafeHandle.cs |
index e547d834986de8d80703504469e9c39b3d8ae93d..a50f35799028ec9b901d64166f7a810799967ddd 100644 |
--- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs |
+++ b/third_party/grpc/src/csharp/Grpc.Core/Internal/ServerCredentialsSafeHandle.cs |
@@ -1,7 +1,6 @@ |
#region Copyright notice and license |
-// Protocol Buffers - Google's data interchange format |
-// Copyright 2008 Google Inc. All rights reserved. |
-// https://developers.google.com/protocol-buffers/ |
+// Copyright 2015-2016, Google Inc. |
+// All rights reserved. |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -29,40 +28,38 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
#endregion |
+using System; |
+using System.Runtime.InteropServices; |
+using System.Threading; |
+using System.Threading.Tasks; |
+using Grpc.Core.Utils; |
-namespace Google.Protobuf.Reflection |
+namespace Grpc.Core.Internal |
{ |
/// <summary> |
- /// Represents a package in the symbol table. We use PackageDescriptors |
- /// just as placeholders so that someone cannot define, say, a message type |
- /// that has the same name as an existing package. |
+ /// grpc_server_credentials from <c>grpc/grpc_security.h</c> |
/// </summary> |
- internal sealed class PackageDescriptor : IDescriptor |
+ internal class ServerCredentialsSafeHandle : SafeHandleZeroIsInvalid |
{ |
- private readonly string name; |
- private readonly string fullName; |
- private readonly FileDescriptor file; |
+ static readonly NativeMethods Native = NativeMethods.Get(); |
- internal PackageDescriptor(string name, string fullName, FileDescriptor file) |
+ private ServerCredentialsSafeHandle() |
{ |
- this.file = file; |
- this.fullName = fullName; |
- this.name = name; |
} |
- public string Name |
+ public static ServerCredentialsSafeHandle CreateSslCredentials(string pemRootCerts, string[] keyCertPairCertChainArray, string[] keyCertPairPrivateKeyArray, bool forceClientAuth) |
{ |
- get { return name; } |
+ GrpcPreconditions.CheckArgument(keyCertPairCertChainArray.Length == keyCertPairPrivateKeyArray.Length); |
+ return Native.grpcsharp_ssl_server_credentials_create(pemRootCerts, |
+ keyCertPairCertChainArray, keyCertPairPrivateKeyArray, |
+ new UIntPtr((ulong)keyCertPairCertChainArray.Length), |
+ forceClientAuth); |
} |
- public string FullName |
+ protected override bool ReleaseHandle() |
{ |
- get { return fullName; } |
- } |
- |
- public FileDescriptor File |
- { |
- get { return file; } |
+ Native.grpcsharp_server_credentials_release(handle); |
+ return true; |
} |
} |
-} |
+} |