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:
authorVladimir Kazakov <vladimir.kazakov@live.com>2017-12-31 16:33:05 +0300
committerMarek Safar <marek.safar@gmail.com>2018-01-03 13:27:20 +0300
commit05e8f2b8d73149e57dfbdbb4d126335a0e17a2bf (patch)
tree451432498158358e36e2a3b88a6562ac8f89454a /mcs/class/corlib
parent5de513945b76d29d9704e167e7ba05f4abfa8c29 (diff)
Add a possibility to use empty X.509 certificates.
Fixes #6264.
Diffstat (limited to 'mcs/class/corlib')
-rw-r--r--mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs7
-rw-r--r--mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Helper.cs4
-rw-r--r--mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509CertificateTest.cs6
3 files changed, 10 insertions, 7 deletions
diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
index 46398d8561d..1e768ca5d46 100644
--- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
+++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
@@ -111,19 +111,15 @@ namespace System.Security.Cryptography.X509Certificates {
internal X509Certificate (X509CertificateImpl impl)
{
- if (impl == null)
- throw new ArgumentNullException ("impl");
-
this.impl = X509Helper.InitFromCertificate (impl);
}
- public X509Certificate (System.Security.Cryptography.X509Certificates.X509Certificate cert)
+ public X509Certificate (X509Certificate cert)
{
if (cert == null)
throw new ArgumentNullException ("cert");
impl = X509Helper.InitFromCertificate (cert);
- hideDates = false;
}
internal void ImportHandle (X509CertificateImpl impl)
@@ -134,7 +130,6 @@ namespace System.Security.Cryptography.X509Certificates {
internal X509CertificateImpl Impl {
get {
- X509Helper.ThrowIfContextInvalid (impl);
return impl;
}
}
diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Helper.cs b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Helper.cs
index 4272f8d2e0b..b4e09881340 100644
--- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Helper.cs
+++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Helper.cs
@@ -136,7 +136,9 @@ namespace System.Security.Cryptography.X509Certificates
public static X509CertificateImpl InitFromCertificate (X509CertificateImpl impl)
{
- ThrowIfContextInvalid (impl);
+ if (impl == null)
+ return null;
+
var copy = impl.Clone ();
if (copy != null)
return copy;
diff --git a/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509CertificateTest.cs b/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509CertificateTest.cs
index 3e6958d083b..634dda0599c 100644
--- a/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509CertificateTest.cs
+++ b/mcs/class/corlib/Test/System.Security.Cryptography.X509Certificates/X509CertificateTest.cs
@@ -82,6 +82,12 @@ public void ConstructorX509CertificateNull ()
X509Certificate nullcopy = new X509Certificate ((X509Certificate) null);
}
+[Test]
+public void X509Certificate_WhenEmptyCertificateProvided_DoesNotThrow ()
+{
+ Assert.DoesNotThrow (() => new X509Certificate (new X509Certificate ()));
+}
+
//-->8-- NON GENERATED CODE ENDS HERE -->8---->8---->8---->8---->8---->8--
// Certificate: basic\COMMERCE.cer