Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <martin.baulig@xamarin.com>2016-09-30 13:55:31 +0300
committerMartin Baulig <martin.baulig@xamarin.com>2016-09-30 14:03:42 +0300
commitd88ce91459ba780eda259fef7537bb956d2505ff (patch)
tree5a203d61cc2ccd28a4af9cf2b43b22615f57619e /mcs/class/System/System.Security.Cryptography.X509Certificates
parentf460c9bb83658ccc6bd3caf958d82bd58a67b6a4 (diff)
[System]: New X509Helper2 APIs for BTLS.
The managed HAVE_BTLS conditionals will be removed once BTLS itself has landed.
Diffstat (limited to 'mcs/class/System/System.Security.Cryptography.X509Certificates')
-rw-r--r--mcs/class/System/System.Security.Cryptography.X509Certificates/X509ChainPolicy.cs3
-rw-r--r--mcs/class/System/System.Security.Cryptography.X509Certificates/X509Helper2.cs66
2 files changed, 68 insertions, 1 deletions
diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509ChainPolicy.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509ChainPolicy.cs
index 1dc234575b8..2fcdd982f33 100644
--- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509ChainPolicy.cs
+++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509ChainPolicy.cs
@@ -91,6 +91,9 @@ namespace System.Security.Cryptography.X509Certificates {
}
return store2;
}
+ internal set {
+ store2 = value;
+ }
}
public X509RevocationFlag RevocationFlag {
diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Helper2.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Helper2.cs
index 2a9163a346f..92709e04fa8 100644
--- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Helper2.cs
+++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Helper2.cs
@@ -37,10 +37,49 @@ using MonoSecurity::Mono.Security.Interface;
using Mono.Security.Interface;
#endif
+#if HAVE_BTLS
+using Mono.Btls;
+#endif
+#endif
+
+using System.IO;
+using System.Text;
+
namespace System.Security.Cryptography.X509Certificates
{
internal static class X509Helper2
{
+ internal static long GetSubjectNameHash (X509Certificate certificate)
+ {
+ return GetSubjectNameHash (certificate.Impl);
+ }
+
+ internal static long GetSubjectNameHash (X509CertificateImpl impl)
+ {
+#if SECURITY_DEP && HAVE_BTLS
+ using (var x509 = GetNativeInstance (impl))
+ return GetSubjectNameHash (x509);
+#else
+ throw new NotSupportedException ();
+#endif
+ }
+
+ internal static void ExportAsPEM (X509Certificate certificate, Stream stream, bool includeHumanReadableForm)
+ {
+ ExportAsPEM (certificate.Impl, stream, includeHumanReadableForm);
+ }
+
+ internal static void ExportAsPEM (X509CertificateImpl impl, Stream stream, bool includeHumanReadableForm)
+ {
+#if SECURITY_DEP && HAVE_BTLS
+ using (var x509 = GetNativeInstance (impl))
+ ExportAsPEM (x509, stream, includeHumanReadableForm);
+#else
+ throw new NotSupportedException ();
+#endif
+ }
+
+#if SECURITY_DEP
internal static void Initialize ()
{
X509Helper.InstallNativeHelper (new MyNativeHelper ());
@@ -51,6 +90,31 @@ namespace System.Security.Cryptography.X509Certificates
X509Helper.ThrowIfContextInvalid (impl);
}
+#if HAVE_BTLS
+ static MonoBtlsX509 GetNativeInstance (X509CertificateImpl impl)
+ {
+ ThrowIfContextInvalid (impl);
+ var btlsImpl = impl as X509CertificateImplBtls;
+ if (btlsImpl != null)
+ return btlsImpl.X509.Copy ();
+ else
+ return MonoBtlsX509.LoadFromData (impl.GetRawCertData (), MonoBtlsX509Format.DER);
+ }
+
+ internal static long GetSubjectNameHash (MonoBtlsX509 x509)
+ {
+ using (var subject = x509.GetSubjectName ())
+ return subject.GetHash ();
+ }
+
+ internal static void ExportAsPEM (MonoBtlsX509 x509, Stream stream, bool includeHumanReadableForm)
+ {
+ using (var bio = MonoBtlsBio.CreateMonoStream (stream)) {
+ x509.ExportAsPEM (bio, includeHumanReadableForm);
+ }
+ }
+#endif
+
internal static X509Certificate2Impl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
var provider = MonoTlsProviderFactory.GetProvider ();
@@ -111,6 +175,6 @@ namespace System.Security.Cryptography.X509Certificates
return X509Helper2.Import (cert);
}
}
+#endif
}
}
-#endif