You've already forked linux-packaging-mono
Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
parent
1190d13a04
commit
6bdd276d05
@@ -1,3 +1,4 @@
|
||||
#if MONO_FEATURE_APPLETLS || MONO_FEATURE_APPLE_X509
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -197,3 +198,4 @@ namespace System.Security.Cryptography.X509Certificates
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,3 +1,4 @@
|
||||
#if MONO_FEATURE_APPLETLS || MONO_FEATURE_APPLE_X509
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using MX = Mono.Security.X509;
|
||||
@@ -7,12 +8,12 @@ namespace System.Security.Cryptography.X509Certificates
|
||||
{
|
||||
static partial class X509Helper
|
||||
{
|
||||
public static X509CertificateImpl InitFromHandle (IntPtr handle)
|
||||
public static X509CertificateImpl InitFromHandleApple (IntPtr handle)
|
||||
{
|
||||
return new X509CertificateImplApple (handle, false);
|
||||
}
|
||||
|
||||
static X509CertificateImpl Import (byte[] rawData)
|
||||
static X509CertificateImpl ImportApple (byte[] rawData)
|
||||
{
|
||||
var handle = CFHelpers.CreateCertificateFromData (rawData);
|
||||
if (handle != IntPtr.Zero)
|
||||
@@ -35,3 +36,4 @@ namespace System.Security.Cryptography.X509Certificates
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@@ -49,6 +49,51 @@ namespace System.Security.Cryptography.X509Certificates
|
||||
Interlocked.CompareExchange (ref nativeHelper, helper, null);
|
||||
}
|
||||
|
||||
#if MONO_FEATURE_APPLETLS
|
||||
static bool ShouldUseAppleTls
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!System.Environment.IsMacOS)
|
||||
return false;
|
||||
// MONO_TLS_PROVIDER values default or apple (not legacy or btls) and must be on MacOS
|
||||
var variable = Environment.GetEnvironmentVariable ("MONO_TLS_PROVIDER");
|
||||
return string.IsNullOrEmpty (variable) || variable == "default" || variable == "apple"; // On Platform.IsMacOS default is AppleTlsProvider
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public static X509CertificateImpl InitFromHandle (IntPtr handle)
|
||||
{
|
||||
#if (MONO_FEATURE_APPLETLS && ONLY_APPLETLS) || MONO_FEATURE_APPLE_X509 // ONLY_APPLETLS should not support any other option
|
||||
return InitFromHandleApple (handle);
|
||||
#else
|
||||
|
||||
#if MONO_FEATURE_APPLETLS // If we support AppleTls, which is the default, and not overriding to legacy
|
||||
if (ShouldUseAppleTls)
|
||||
return InitFromHandleApple (handle);
|
||||
#endif
|
||||
#if !MOBILE
|
||||
return InitFromHandleCore (handle);
|
||||
#elif !MONOTOUCH && !XAMMAC
|
||||
throw new NotSupportedException ();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static X509CertificateImpl Import (byte[] rawData)
|
||||
{
|
||||
#if (MONO_FEATURE_APPLETLS && ONLY_APPLETLS) || MONO_FEATURE_APPLE_X509 // ONLY_APPLETLS should not support any other option
|
||||
return ImportApple (rawData);
|
||||
#else
|
||||
#if MONO_FEATURE_APPLETLS
|
||||
if (ShouldUseAppleTls)
|
||||
return ImportApple (rawData);
|
||||
#endif
|
||||
return ImportCore (rawData);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
// typedef struct _CERT_CONTEXT {
|
||||
// DWORD dwCertEncodingType;
|
||||
@@ -70,7 +115,7 @@ namespace System.Security.Cryptography.X509Certificates
|
||||
// so we don't create any dependencies on Windows DLL in corlib
|
||||
|
||||
[SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
|
||||
public static X509CertificateImpl InitFromHandle (IntPtr handle)
|
||||
public static X509CertificateImpl InitFromHandleCore (IntPtr handle)
|
||||
{
|
||||
// both Marshal.PtrToStructure and Marshal.Copy use LinkDemand (so they will always success from here)
|
||||
CertificateContext cc = (CertificateContext) Marshal.PtrToStructure (handle, typeof (CertificateContext));
|
||||
@@ -79,11 +124,6 @@ namespace System.Security.Cryptography.X509Certificates
|
||||
var x509 = new MX.X509Certificate (data);
|
||||
return new X509CertificateImplMono (x509);
|
||||
}
|
||||
#elif !MONOTOUCH && !XAMMAC
|
||||
public static X509CertificateImpl InitFromHandle (IntPtr handle)
|
||||
{
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
#endif
|
||||
|
||||
public static X509CertificateImpl InitFromCertificate (X509Certificate cert)
|
||||
@@ -175,8 +215,7 @@ namespace System.Security.Cryptography.X509Certificates
|
||||
return data;
|
||||
}
|
||||
|
||||
#if !MONOTOUCH && !XAMMAC
|
||||
static X509CertificateImpl Import (byte[] rawData)
|
||||
static X509CertificateImpl ImportCore (byte[] rawData)
|
||||
{
|
||||
MX.X509Certificate x509;
|
||||
try {
|
||||
@@ -193,7 +232,6 @@ namespace System.Security.Cryptography.X509Certificates
|
||||
|
||||
return new X509CertificateImplMono (x509);
|
||||
}
|
||||
#endif
|
||||
|
||||
public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
|
||||
{
|
||||
|
Reference in New Issue
Block a user