diff --git a/pkg/Microsoft.Private.PackageBaseline/packageIndex.json b/pkg/Microsoft.Private.PackageBaseline/packageIndex.json
index 0a131d884135..99640621c1a0 100644
--- a/pkg/Microsoft.Private.PackageBaseline/packageIndex.json
+++ b/pkg/Microsoft.Private.PackageBaseline/packageIndex.json
@@ -2198,7 +2198,7 @@
"4.0.0.0": "4.1.0",
"4.1.0.0": "4.1.0",
"4.1.1.0": "4.3.0",
- "4.1.2.0": "4.4.0"
+ "4.2.0.0": "4.4.0"
}
},
"System.Security.Principal": {
diff --git a/src/System.Security.Cryptography.X509Certificates/dir.props b/src/System.Security.Cryptography.X509Certificates/dir.props
index d8b54a28a28b..1af9800f258e 100644
--- a/src/System.Security.Cryptography.X509Certificates/dir.props
+++ b/src/System.Security.Cryptography.X509Certificates/dir.props
@@ -2,6 +2,6 @@
- 4.1.2.0
+ 4.2.0.0
\ No newline at end of file
diff --git a/src/System.Security.Cryptography.X509Certificates/pkg/System.Security.Cryptography.X509Certificates.pkgproj b/src/System.Security.Cryptography.X509Certificates/pkg/System.Security.Cryptography.X509Certificates.pkgproj
index b6ab907a1c54..5be94174bee7 100644
--- a/src/System.Security.Cryptography.X509Certificates/pkg/System.Security.Cryptography.X509Certificates.pkgproj
+++ b/src/System.Security.Cryptography.X509Certificates/pkg/System.Security.Cryptography.X509Certificates.pkgproj
@@ -2,11 +2,8 @@
-
- net46
-
- net461;netcore50;netcoreapp1.0;$(AllXamarinFrameworks)
+ net463;netcoreapp1.1;$(AllXamarinFrameworks)
diff --git a/src/System.Security.Cryptography.X509Certificates/ref/4.0/System.Security.Cryptography.X509Certificates.Manual.cs b/src/System.Security.Cryptography.X509Certificates/ref/4.0/System.Security.Cryptography.X509Certificates.Manual.cs
deleted file mode 100644
index d23fdabbde28..000000000000
--- a/src/System.Security.Cryptography.X509Certificates/ref/4.0/System.Security.Cryptography.X509Certificates.Manual.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-namespace Microsoft.Win32.SafeHandles
-{
- // Members from SafeHandleMinusOneOrZeroIsInvalid needed after removing base
- public sealed partial class SafeX509ChainHandle
- {
- public override bool IsInvalid {[System.Security.SecurityCriticalAttribute]get { return default(bool); } }
- }
-}
-
-namespace System.Security.Cryptography.X509Certificates
-{
- // Declaring members from stripped base class CollectionBase
- public partial class X509CertificateCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
- {
- public int Count { get { return default(int); } }
- bool System.Collections.ICollection.IsSynchronized { get { return default(bool); } }
- object System.Collections.ICollection.SyncRoot { get { return default(object); } }
- bool System.Collections.IList.IsFixedSize { get { return default(bool); } }
- bool System.Collections.IList.IsReadOnly { get { return default(bool); } }
- object System.Collections.IList.this[int index] { get { return default(object); } set { } }
- public void Clear() { }
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return default(System.Collections.IEnumerator); }
- public void RemoveAt(int index) { }
- void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
- int System.Collections.IList.Add(object value) { return default(int); }
- bool System.Collections.IList.Contains(object value) { return default(bool); }
- int System.Collections.IList.IndexOf(object value) { return default(int); }
- void System.Collections.IList.Insert(int index, object value) { }
- void System.Collections.IList.Remove(object value) { }
- }
-}
diff --git a/src/System.Security.Cryptography.X509Certificates/ref/4.0/System.Security.Cryptography.X509Certificates.cs b/src/System.Security.Cryptography.X509Certificates/ref/4.0/System.Security.Cryptography.X509Certificates.cs
deleted file mode 100644
index c9155c8ab00e..000000000000
--- a/src/System.Security.Cryptography.X509Certificates/ref/4.0/System.Security.Cryptography.X509Certificates.cs
+++ /dev/null
@@ -1,466 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// ------------------------------------------------------------------------------
-// Changes to this file must follow the http://aka.ms/api-review process.
-// ------------------------------------------------------------------------------
-
-
-namespace Microsoft.Win32.SafeHandles
-{
- public sealed partial class SafeX509ChainHandle : System.Runtime.InteropServices.SafeHandle
- {
- internal SafeX509ChainHandle() : base(default(System.IntPtr), default(bool)) { }
- protected override bool ReleaseHandle() { return default(bool); }
- }
-}
-namespace System.Security.Cryptography.X509Certificates
-{
- [System.FlagsAttribute]
- public enum OpenFlags
- {
- IncludeArchived = 8,
- MaxAllowed = 2,
- OpenExistingOnly = 4,
- ReadOnly = 0,
- ReadWrite = 1,
- }
- public sealed partial class PublicKey
- {
- public PublicKey(System.Security.Cryptography.Oid oid, System.Security.Cryptography.AsnEncodedData parameters, System.Security.Cryptography.AsnEncodedData keyValue) { }
- public System.Security.Cryptography.AsnEncodedData EncodedKeyValue { get { return default(System.Security.Cryptography.AsnEncodedData); } }
- public System.Security.Cryptography.AsnEncodedData EncodedParameters { get { return default(System.Security.Cryptography.AsnEncodedData); } }
- public System.Security.Cryptography.Oid Oid { get { return default(System.Security.Cryptography.Oid); } }
- }
- public static partial class RSACertificateExtensions
- {
- public static System.Security.Cryptography.RSA GetRSAPrivateKey(this System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { return default(System.Security.Cryptography.RSA); }
- public static System.Security.Cryptography.RSA GetRSAPublicKey(this System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { return default(System.Security.Cryptography.RSA); }
- }
- public enum StoreLocation
- {
- CurrentUser = 1,
- LocalMachine = 2,
- }
- public enum StoreName
- {
- AddressBook = 1,
- AuthRoot = 2,
- CertificateAuthority = 3,
- Disallowed = 4,
- My = 5,
- Root = 6,
- TrustedPeople = 7,
- TrustedPublisher = 8,
- }
- public sealed partial class X500DistinguishedName : System.Security.Cryptography.AsnEncodedData
- {
- public X500DistinguishedName(byte[] encodedDistinguishedName) { }
- public X500DistinguishedName(System.Security.Cryptography.AsnEncodedData encodedDistinguishedName) { }
- public X500DistinguishedName(System.Security.Cryptography.X509Certificates.X500DistinguishedName distinguishedName) { }
- public X500DistinguishedName(string distinguishedName) { }
- public X500DistinguishedName(string distinguishedName, System.Security.Cryptography.X509Certificates.X500DistinguishedNameFlags flag) { }
- public string Name { get { return default(string); } }
- public string Decode(System.Security.Cryptography.X509Certificates.X500DistinguishedNameFlags flag) { return default(string); }
- public override string Format(bool multiLine) { return default(string); }
- }
- [System.FlagsAttribute]
- public enum X500DistinguishedNameFlags
- {
- DoNotUsePlusSign = 32,
- DoNotUseQuotes = 64,
- ForceUTF8Encoding = 16384,
- None = 0,
- Reversed = 1,
- UseCommas = 128,
- UseNewLines = 256,
- UseSemicolons = 16,
- UseT61Encoding = 8192,
- UseUTF8Encoding = 4096,
- }
- public sealed partial class X509BasicConstraintsExtension : System.Security.Cryptography.X509Certificates.X509Extension
- {
- public X509BasicConstraintsExtension() { }
- public X509BasicConstraintsExtension(bool certificateAuthority, bool hasPathLengthConstraint, int pathLengthConstraint, bool critical) { }
- public X509BasicConstraintsExtension(System.Security.Cryptography.AsnEncodedData encodedBasicConstraints, bool critical) { }
- public bool CertificateAuthority { get { return default(bool); } }
- public bool HasPathLengthConstraint { get { return default(bool); } }
- public int PathLengthConstraint { get { return default(int); } }
- public override void CopyFrom(System.Security.Cryptography.AsnEncodedData asnEncodedData) { }
- }
- public partial class X509Certificate : System.IDisposable
- {
- public X509Certificate() { }
- public X509Certificate(byte[] data) { }
- public X509Certificate(byte[] rawData, string password) { }
- public X509Certificate(byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { }
- [System.Security.SecurityCriticalAttribute]
- public X509Certificate(System.IntPtr handle) { }
- public X509Certificate(string fileName) { }
- public X509Certificate(string fileName, string password) { }
- public X509Certificate(string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { }
- public System.IntPtr Handle {[System.Security.SecurityCriticalAttribute]get { return default(System.IntPtr); } }
- public string Issuer { get { return default(string); } }
- public string Subject { get { return default(string); } }
- public void Dispose() { }
- protected virtual void Dispose(bool disposing) { }
- public override bool Equals(object obj) { return default(bool); }
- public virtual bool Equals(System.Security.Cryptography.X509Certificates.X509Certificate other) { return default(bool); }
- public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType) { return default(byte[]); }
- public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, string password) { return default(byte[]); }
- public virtual byte[] GetCertHash() { return default(byte[]); }
- public virtual string GetFormat() { return default(string); }
- public override int GetHashCode() { return default(int); }
- public virtual string GetKeyAlgorithm() { return default(string); }
- public virtual byte[] GetKeyAlgorithmParameters() { return default(byte[]); }
- public virtual string GetKeyAlgorithmParametersString() { return default(string); }
- public virtual byte[] GetPublicKey() { return default(byte[]); }
- public virtual byte[] GetSerialNumber() { return default(byte[]); }
- public override string ToString() { return default(string); }
- public virtual string ToString(bool fVerbose) { return default(string); }
- }
- public partial class X509Certificate2 : System.Security.Cryptography.X509Certificates.X509Certificate
- {
- public X509Certificate2() { }
- public X509Certificate2(byte[] rawData) { }
- public X509Certificate2(byte[] rawData, string password) { }
- public X509Certificate2(byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { }
- public X509Certificate2(System.IntPtr handle) { }
- public X509Certificate2(string fileName) { }
- public X509Certificate2(string fileName, string password) { }
- public X509Certificate2(string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { }
- public bool Archived { get { return default(bool); } set { } }
- public System.Security.Cryptography.X509Certificates.X509ExtensionCollection Extensions { get { return default(System.Security.Cryptography.X509Certificates.X509ExtensionCollection); } }
- public string FriendlyName { get { return default(string); } set { } }
- public bool HasPrivateKey { get { return default(bool); } }
- public System.Security.Cryptography.X509Certificates.X500DistinguishedName IssuerName { get { return default(System.Security.Cryptography.X509Certificates.X500DistinguishedName); } }
- public System.DateTime NotAfter { get { return default(System.DateTime); } }
- public System.DateTime NotBefore { get { return default(System.DateTime); } }
- public System.Security.Cryptography.X509Certificates.PublicKey PublicKey { get { return default(System.Security.Cryptography.X509Certificates.PublicKey); } }
- public byte[] RawData { get { return default(byte[]); } }
- public string SerialNumber { get { return default(string); } }
- public System.Security.Cryptography.Oid SignatureAlgorithm { get { return default(System.Security.Cryptography.Oid); } }
- public System.Security.Cryptography.X509Certificates.X500DistinguishedName SubjectName { get { return default(System.Security.Cryptography.X509Certificates.X500DistinguishedName); } }
- public string Thumbprint { get { return default(string); } }
- public int Version { get { return default(int); } }
- public static System.Security.Cryptography.X509Certificates.X509ContentType GetCertContentType(byte[] rawData) { return default(System.Security.Cryptography.X509Certificates.X509ContentType); }
- public static System.Security.Cryptography.X509Certificates.X509ContentType GetCertContentType(string fileName) { return default(System.Security.Cryptography.X509Certificates.X509ContentType); }
- public string GetNameInfo(System.Security.Cryptography.X509Certificates.X509NameType nameType, bool forIssuer) { return default(string); }
- public override string ToString() { return default(string); }
- public override string ToString(bool verbose) { return default(string); }
- }
- public partial class X509Certificate2Collection : System.Security.Cryptography.X509Certificates.X509CertificateCollection
- {
- public X509Certificate2Collection() { }
- public X509Certificate2Collection(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
- public X509Certificate2Collection(System.Security.Cryptography.X509Certificates.X509Certificate2[] certificates) { }
- public X509Certificate2Collection(System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates) { }
- public new System.Security.Cryptography.X509Certificates.X509Certificate2 this[int index] { get { return default(System.Security.Cryptography.X509Certificates.X509Certificate2); } set { } }
- public int Add(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { return default(int); }
- public void AddRange(System.Security.Cryptography.X509Certificates.X509Certificate2[] certificates) { }
- public void AddRange(System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates) { }
- public bool Contains(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { return default(bool); }
- public byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType) { return default(byte[]); }
- public byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, string password) { return default(byte[]); }
- public System.Security.Cryptography.X509Certificates.X509Certificate2Collection Find(System.Security.Cryptography.X509Certificates.X509FindType findType, object findValue, bool validOnly) { return default(System.Security.Cryptography.X509Certificates.X509Certificate2Collection); }
- public new System.Security.Cryptography.X509Certificates.X509Certificate2Enumerator GetEnumerator() { return default(System.Security.Cryptography.X509Certificates.X509Certificate2Enumerator); }
- public void Import(byte[] rawData) { }
- public void Import(byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { }
- public void Import(string fileName) { }
- public void Import(string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { }
- public void Insert(int index, System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
- public void Remove(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
- public void RemoveRange(System.Security.Cryptography.X509Certificates.X509Certificate2[] certificates) { }
- public void RemoveRange(System.Security.Cryptography.X509Certificates.X509Certificate2Collection certificates) { }
- }
- public sealed partial class X509Certificate2Enumerator : System.Collections.IEnumerator
- {
- internal X509Certificate2Enumerator() { }
- public System.Security.Cryptography.X509Certificates.X509Certificate2 Current { get { return default(System.Security.Cryptography.X509Certificates.X509Certificate2); } }
- object System.Collections.IEnumerator.Current { get { return default(object); } }
- public bool MoveNext() { return default(bool); }
- public void Reset() { }
- bool System.Collections.IEnumerator.MoveNext() { return default(bool); }
- void System.Collections.IEnumerator.Reset() { }
- }
- public partial class X509CertificateCollection
- {
- public X509CertificateCollection() { }
- public X509CertificateCollection(System.Security.Cryptography.X509Certificates.X509Certificate[] value) { }
- public X509CertificateCollection(System.Security.Cryptography.X509Certificates.X509CertificateCollection value) { }
- public System.Security.Cryptography.X509Certificates.X509Certificate this[int index] { get { return default(System.Security.Cryptography.X509Certificates.X509Certificate); } set { } }
- public int Add(System.Security.Cryptography.X509Certificates.X509Certificate value) { return default(int); }
- public void AddRange(System.Security.Cryptography.X509Certificates.X509Certificate[] value) { }
- public void AddRange(System.Security.Cryptography.X509Certificates.X509CertificateCollection value) { }
- public bool Contains(System.Security.Cryptography.X509Certificates.X509Certificate value) { return default(bool); }
- public void CopyTo(System.Security.Cryptography.X509Certificates.X509Certificate[] array, int index) { }
- public System.Security.Cryptography.X509Certificates.X509CertificateCollection.X509CertificateEnumerator GetEnumerator() { return default(System.Security.Cryptography.X509Certificates.X509CertificateCollection.X509CertificateEnumerator); }
- public override int GetHashCode() { return default(int); }
- public int IndexOf(System.Security.Cryptography.X509Certificates.X509Certificate value) { return default(int); }
- public void Insert(int index, System.Security.Cryptography.X509Certificates.X509Certificate value) { }
- public void Remove(System.Security.Cryptography.X509Certificates.X509Certificate value) { }
- public partial class X509CertificateEnumerator : System.Collections.IEnumerator
- {
- public X509CertificateEnumerator(System.Security.Cryptography.X509Certificates.X509CertificateCollection mappings) { }
- public System.Security.Cryptography.X509Certificates.X509Certificate Current { get { return default(System.Security.Cryptography.X509Certificates.X509Certificate); } }
- object System.Collections.IEnumerator.Current { get { return default(object); } }
- public bool MoveNext() { return default(bool); }
- public void Reset() { }
- bool System.Collections.IEnumerator.MoveNext() { return default(bool); }
- void System.Collections.IEnumerator.Reset() { }
- }
- }
- public partial class X509Chain : System.IDisposable
- {
- public X509Chain() { }
- public System.Security.Cryptography.X509Certificates.X509ChainElementCollection ChainElements { get { return default(System.Security.Cryptography.X509Certificates.X509ChainElementCollection); } }
- public System.Security.Cryptography.X509Certificates.X509ChainPolicy ChainPolicy { get { return default(System.Security.Cryptography.X509Certificates.X509ChainPolicy); } set { } }
- public System.Security.Cryptography.X509Certificates.X509ChainStatus[] ChainStatus { get { return default(System.Security.Cryptography.X509Certificates.X509ChainStatus[]); } }
- public Microsoft.Win32.SafeHandles.SafeX509ChainHandle SafeHandle { get { return default(Microsoft.Win32.SafeHandles.SafeX509ChainHandle); } }
- public bool Build(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { return default(bool); }
- public void Dispose() { }
- protected virtual void Dispose(bool disposing) { }
- }
- public partial class X509ChainElement
- {
- internal X509ChainElement() { }
- public System.Security.Cryptography.X509Certificates.X509Certificate2 Certificate { get { return default(System.Security.Cryptography.X509Certificates.X509Certificate2); } }
- public System.Security.Cryptography.X509Certificates.X509ChainStatus[] ChainElementStatus { get { return default(System.Security.Cryptography.X509Certificates.X509ChainStatus[]); } }
- public string Information { get { return default(string); } }
- }
- public sealed partial class X509ChainElementCollection : System.Collections.ICollection, System.Collections.IEnumerable
- {
- internal X509ChainElementCollection() { }
- public int Count { get { return default(int); } }
- bool System.Collections.ICollection.IsSynchronized { get { return default(bool); } }
- public System.Security.Cryptography.X509Certificates.X509ChainElement this[int index] { get { return default(System.Security.Cryptography.X509Certificates.X509ChainElement); } }
- object System.Collections.ICollection.SyncRoot { get { return default(object); } }
- public void CopyTo(System.Security.Cryptography.X509Certificates.X509ChainElement[] array, int index) { }
- public System.Security.Cryptography.X509Certificates.X509ChainElementEnumerator GetEnumerator() { return default(System.Security.Cryptography.X509Certificates.X509ChainElementEnumerator); }
- void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return default(System.Collections.IEnumerator); }
- }
- public sealed partial class X509ChainElementEnumerator : System.Collections.IEnumerator
- {
- internal X509ChainElementEnumerator() { }
- public System.Security.Cryptography.X509Certificates.X509ChainElement Current { get { return default(System.Security.Cryptography.X509Certificates.X509ChainElement); } }
- object System.Collections.IEnumerator.Current { get { return default(object); } }
- public bool MoveNext() { return default(bool); }
- public void Reset() { }
- }
- public sealed partial class X509ChainPolicy
- {
- public X509ChainPolicy() { }
- public System.Security.Cryptography.OidCollection ApplicationPolicy { get { return default(System.Security.Cryptography.OidCollection); } }
- public System.Security.Cryptography.OidCollection CertificatePolicy { get { return default(System.Security.Cryptography.OidCollection); } }
- public System.Security.Cryptography.X509Certificates.X509Certificate2Collection ExtraStore { get { return default(System.Security.Cryptography.X509Certificates.X509Certificate2Collection); } }
- public System.Security.Cryptography.X509Certificates.X509RevocationFlag RevocationFlag { get { return default(System.Security.Cryptography.X509Certificates.X509RevocationFlag); } set { } }
- public System.Security.Cryptography.X509Certificates.X509RevocationMode RevocationMode { get { return default(System.Security.Cryptography.X509Certificates.X509RevocationMode); } set { } }
- public System.TimeSpan UrlRetrievalTimeout { get { return default(System.TimeSpan); } set { } }
- public System.Security.Cryptography.X509Certificates.X509VerificationFlags VerificationFlags { get { return default(System.Security.Cryptography.X509Certificates.X509VerificationFlags); } set { } }
- public System.DateTime VerificationTime { get { return default(System.DateTime); } set { } }
- public void Reset() { }
- }
- [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
- public partial struct X509ChainStatus
- {
- public System.Security.Cryptography.X509Certificates.X509ChainStatusFlags Status { get { return default(System.Security.Cryptography.X509Certificates.X509ChainStatusFlags); } set { } }
- public string StatusInformation { get { return default(string); } set { } }
- }
- [System.FlagsAttribute]
- public enum X509ChainStatusFlags
- {
- CtlNotSignatureValid = 262144,
- CtlNotTimeValid = 131072,
- CtlNotValidForUsage = 524288,
- Cyclic = 128,
- HasExcludedNameConstraint = 32768,
- HasNotDefinedNameConstraint = 8192,
- HasNotPermittedNameConstraint = 16384,
- HasNotSupportedNameConstraint = 4096,
- InvalidBasicConstraints = 1024,
- InvalidExtension = 256,
- InvalidNameConstraints = 2048,
- InvalidPolicyConstraints = 512,
- NoError = 0,
- NoIssuanceChainPolicy = 33554432,
- NotSignatureValid = 8,
- NotTimeNested = 2,
- NotTimeValid = 1,
- NotValidForUsage = 16,
- OfflineRevocation = 16777216,
- PartialChain = 65536,
- RevocationStatusUnknown = 64,
- Revoked = 4,
- UntrustedRoot = 32,
- }
- public enum X509ContentType
- {
- Authenticode = 6,
- Cert = 1,
- Pfx = 3,
- Pkcs12 = 3,
- Pkcs7 = 5,
- SerializedCert = 2,
- SerializedStore = 4,
- Unknown = 0,
- }
- public sealed partial class X509EnhancedKeyUsageExtension : System.Security.Cryptography.X509Certificates.X509Extension
- {
- public X509EnhancedKeyUsageExtension() { }
- public X509EnhancedKeyUsageExtension(System.Security.Cryptography.AsnEncodedData encodedEnhancedKeyUsages, bool critical) { }
- public X509EnhancedKeyUsageExtension(System.Security.Cryptography.OidCollection enhancedKeyUsages, bool critical) { }
- public System.Security.Cryptography.OidCollection EnhancedKeyUsages { get { return default(System.Security.Cryptography.OidCollection); } }
- public override void CopyFrom(System.Security.Cryptography.AsnEncodedData asnEncodedData) { }
- }
- public partial class X509Extension : System.Security.Cryptography.AsnEncodedData
- {
- protected X509Extension() { }
- public X509Extension(System.Security.Cryptography.AsnEncodedData encodedExtension, bool critical) { }
- public X509Extension(System.Security.Cryptography.Oid oid, byte[] rawData, bool critical) { }
- public X509Extension(string oid, byte[] rawData, bool critical) { }
- public bool Critical { get { return default(bool); } set { } }
- public override void CopyFrom(System.Security.Cryptography.AsnEncodedData asnEncodedData) { }
- }
- public sealed partial class X509ExtensionCollection : System.Collections.ICollection, System.Collections.IEnumerable
- {
- public X509ExtensionCollection() { }
- public int Count { get { return default(int); } }
- bool System.Collections.ICollection.IsSynchronized { get { return default(bool); } }
- public System.Security.Cryptography.X509Certificates.X509Extension this[int index] { get { return default(System.Security.Cryptography.X509Certificates.X509Extension); } }
- public System.Security.Cryptography.X509Certificates.X509Extension this[string oid] { get { return default(System.Security.Cryptography.X509Certificates.X509Extension); } }
- object System.Collections.ICollection.SyncRoot { get { return default(object); } }
- public int Add(System.Security.Cryptography.X509Certificates.X509Extension extension) { return default(int); }
- public void CopyTo(System.Security.Cryptography.X509Certificates.X509Extension[] array, int index) { }
- public System.Security.Cryptography.X509Certificates.X509ExtensionEnumerator GetEnumerator() { return default(System.Security.Cryptography.X509Certificates.X509ExtensionEnumerator); }
- void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return default(System.Collections.IEnumerator); }
- }
- public sealed partial class X509ExtensionEnumerator : System.Collections.IEnumerator
- {
- internal X509ExtensionEnumerator() { }
- public System.Security.Cryptography.X509Certificates.X509Extension Current { get { return default(System.Security.Cryptography.X509Certificates.X509Extension); } }
- object System.Collections.IEnumerator.Current { get { return default(object); } }
- public bool MoveNext() { return default(bool); }
- public void Reset() { }
- }
- public enum X509FindType
- {
- FindByApplicationPolicy = 10,
- FindByCertificatePolicy = 11,
- FindByExtension = 12,
- FindByIssuerDistinguishedName = 4,
- FindByIssuerName = 3,
- FindByKeyUsage = 13,
- FindBySerialNumber = 5,
- FindBySubjectDistinguishedName = 2,
- FindBySubjectKeyIdentifier = 14,
- FindBySubjectName = 1,
- FindByTemplateName = 9,
- FindByThumbprint = 0,
- FindByTimeExpired = 8,
- FindByTimeNotYetValid = 7,
- FindByTimeValid = 6,
- }
- [System.FlagsAttribute]
- public enum X509KeyStorageFlags
- {
- DefaultKeySet = 0,
- Exportable = 4,
- MachineKeySet = 2,
- PersistKeySet = 16,
- UserKeySet = 1,
- UserProtected = 8,
- }
- public sealed partial class X509KeyUsageExtension : System.Security.Cryptography.X509Certificates.X509Extension
- {
- public X509KeyUsageExtension() { }
- public X509KeyUsageExtension(System.Security.Cryptography.AsnEncodedData encodedKeyUsage, bool critical) { }
- public X509KeyUsageExtension(System.Security.Cryptography.X509Certificates.X509KeyUsageFlags keyUsages, bool critical) { }
- public System.Security.Cryptography.X509Certificates.X509KeyUsageFlags KeyUsages { get { return default(System.Security.Cryptography.X509Certificates.X509KeyUsageFlags); } }
- public override void CopyFrom(System.Security.Cryptography.AsnEncodedData asnEncodedData) { }
- }
- [System.FlagsAttribute]
- public enum X509KeyUsageFlags
- {
- CrlSign = 2,
- DataEncipherment = 16,
- DecipherOnly = 32768,
- DigitalSignature = 128,
- EncipherOnly = 1,
- KeyAgreement = 8,
- KeyCertSign = 4,
- KeyEncipherment = 32,
- None = 0,
- NonRepudiation = 64,
- }
- public enum X509NameType
- {
- DnsFromAlternativeName = 4,
- DnsName = 3,
- EmailName = 1,
- SimpleName = 0,
- UpnName = 2,
- UrlName = 5,
- }
- public enum X509RevocationFlag
- {
- EndCertificateOnly = 0,
- EntireChain = 1,
- ExcludeRoot = 2,
- }
- public enum X509RevocationMode
- {
- NoCheck = 0,
- Offline = 2,
- Online = 1,
- }
- public sealed partial class X509Store : System.IDisposable
- {
- public X509Store() { }
- public X509Store(System.Security.Cryptography.X509Certificates.StoreName storeName, System.Security.Cryptography.X509Certificates.StoreLocation storeLocation) { }
- public X509Store(string storeName, System.Security.Cryptography.X509Certificates.StoreLocation storeLocation) { }
- public System.Security.Cryptography.X509Certificates.X509Certificate2Collection Certificates { get { return default(System.Security.Cryptography.X509Certificates.X509Certificate2Collection); } }
- public System.Security.Cryptography.X509Certificates.StoreLocation Location { get { return default(System.Security.Cryptography.X509Certificates.StoreLocation); } }
- public string Name { get { return default(string); } }
- public void Add(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
- public void Dispose() { }
- public void Open(System.Security.Cryptography.X509Certificates.OpenFlags flags) { }
- public void Remove(System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) { }
- }
- public sealed partial class X509SubjectKeyIdentifierExtension : System.Security.Cryptography.X509Certificates.X509Extension
- {
- public X509SubjectKeyIdentifierExtension() { }
- public X509SubjectKeyIdentifierExtension(byte[] subjectKeyIdentifier, bool critical) { }
- public X509SubjectKeyIdentifierExtension(System.Security.Cryptography.AsnEncodedData encodedSubjectKeyIdentifier, bool critical) { }
- public X509SubjectKeyIdentifierExtension(System.Security.Cryptography.X509Certificates.PublicKey key, bool critical) { }
- public X509SubjectKeyIdentifierExtension(System.Security.Cryptography.X509Certificates.PublicKey key, System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierHashAlgorithm algorithm, bool critical) { }
- public X509SubjectKeyIdentifierExtension(string subjectKeyIdentifier, bool critical) { }
- public string SubjectKeyIdentifier { get { return default(string); } }
- public override void CopyFrom(System.Security.Cryptography.AsnEncodedData asnEncodedData) { }
- }
- public enum X509SubjectKeyIdentifierHashAlgorithm
- {
- CapiSha1 = 2,
- Sha1 = 0,
- ShortSha1 = 1,
- }
- [System.FlagsAttribute]
- public enum X509VerificationFlags
- {
- AllFlags = 4095,
- AllowUnknownCertificateAuthority = 16,
- IgnoreCertificateAuthorityRevocationUnknown = 1024,
- IgnoreCtlNotTimeValid = 2,
- IgnoreCtlSignerRevocationUnknown = 512,
- IgnoreEndRevocationUnknown = 256,
- IgnoreInvalidBasicConstraints = 8,
- IgnoreInvalidName = 64,
- IgnoreInvalidPolicy = 128,
- IgnoreNotTimeNested = 4,
- IgnoreNotTimeValid = 1,
- IgnoreRootRevocationUnknown = 2048,
- IgnoreWrongUsage = 32,
- NoFlag = 0,
- }
-}
diff --git a/src/System.Security.Cryptography.X509Certificates/ref/4.0/System.Security.Cryptography.X509Certificates.csproj b/src/System.Security.Cryptography.X509Certificates/ref/4.0/System.Security.Cryptography.X509Certificates.csproj
deleted file mode 100644
index e3e49704cfd1..000000000000
--- a/src/System.Security.Cryptography.X509Certificates/ref/4.0/System.Security.Cryptography.X509Certificates.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
- 4.0.0.0
- Library
- .NETStandard,Version=v1.3
-
-
-
-
-
-
-
-
-
-
diff --git a/src/System.Security.Cryptography.X509Certificates/ref/4.0/project.json b/src/System.Security.Cryptography.X509Certificates/ref/4.0/project.json
deleted file mode 100644
index dfaeaf754921..000000000000
--- a/src/System.Security.Cryptography.X509Certificates/ref/4.0/project.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "dependencies": {
- "System.IO": "4.0.0",
- "System.Runtime": "4.0.0",
- "System.Runtime.Handles": "4.0.0",
- "System.Security.Cryptography.Primitives": "4.0.0",
- "System.Security.Cryptography.Algorithms": "4.2.0",
- "System.Security.Cryptography.Encoding": "4.0.0"
- },
- "frameworks": {
- "netstandard1.3": {
- "imports": [
- "dotnet5.4"
- ]
- }
- }
-}
diff --git a/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.Manual.cs b/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.Manual.cs
deleted file mode 100644
index b3bf6763fb81..000000000000
--- a/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.Manual.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-// ------------------------------------------------------------------------------
-// Changes to this file must follow the http://aka.ms/api-review process.
-// ------------------------------------------------------------------------------
-
-namespace Microsoft.Win32.SafeHandles
-{
- // Members from SafeHandleMinusOneOrZeroIsInvalid needed after removing base
- public sealed partial class SafeX509ChainHandle
- {
- public override bool IsInvalid {[System.Security.SecurityCriticalAttribute]get { return default(bool); } }
- }
-}
-
-namespace System.Security.Cryptography.X509Certificates
-{
- // Declaring members from stripped base class CollectionBase
- public partial class X509CertificateCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
- {
- public int Count { get { return default(int); } }
- bool System.Collections.ICollection.IsSynchronized { get { return default(bool); } }
- object System.Collections.ICollection.SyncRoot { get { return default(object); } }
- bool System.Collections.IList.IsFixedSize { get { return default(bool); } }
- bool System.Collections.IList.IsReadOnly { get { return default(bool); } }
- object System.Collections.IList.this[int index] { get { return default(object); } set { } }
- public void Clear() { }
- System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return default(System.Collections.IEnumerator); }
- public void RemoveAt(int index) { }
- void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
- int System.Collections.IList.Add(object value) { return default(int); }
- bool System.Collections.IList.Contains(object value) { return default(bool); }
- int System.Collections.IList.IndexOf(object value) { return default(int); }
- void System.Collections.IList.Insert(int index, object value) { }
- void System.Collections.IList.Remove(object value) { }
- }
-}
diff --git a/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.cs b/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.cs
index d8cee707eaa9..164229795a47 100644
--- a/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.cs
+++ b/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.cs
@@ -5,15 +5,17 @@
// Changes to this file must follow the http://aka.ms/api-review process.
// ------------------------------------------------------------------------------
-
namespace Microsoft.Win32.SafeHandles
{
public sealed partial class SafeX509ChainHandle : System.Runtime.InteropServices.SafeHandle
{
internal SafeX509ChainHandle() : base(default(System.IntPtr), default(bool)) { }
+ public override bool IsInvalid { get { return default(bool); } }
+ protected override void Dispose(bool disposing) { }
protected override bool ReleaseHandle() { return default(bool); }
}
}
+
namespace System.Security.Cryptography.X509Certificates
{
public static partial class ECDsaCertificateExtensions
@@ -99,12 +101,12 @@ public X509Certificate() { }
public X509Certificate(byte[] data) { }
public X509Certificate(byte[] rawData, string password) { }
public X509Certificate(byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { }
- [System.Security.SecurityCriticalAttribute]
public X509Certificate(System.IntPtr handle) { }
+ public X509Certificate(System.Security.Cryptography.X509Certificates.X509Certificate cert) { }
public X509Certificate(string fileName) { }
public X509Certificate(string fileName, string password) { }
public X509Certificate(string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { }
- public System.IntPtr Handle {[System.Security.SecurityCriticalAttribute]get { return default(System.IntPtr); } }
+ public System.IntPtr Handle { get { return default(System.IntPtr); } }
public string Issuer { get { return default(string); } }
public string Subject { get { return default(string); } }
public void Dispose() { }
@@ -114,13 +116,24 @@ protected virtual void Dispose(bool disposing) { }
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType) { return default(byte[]); }
public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, string password) { return default(byte[]); }
public virtual byte[] GetCertHash() { return default(byte[]); }
+ public virtual string GetCertHashString() { return default(string); }
+ public virtual string GetEffectiveDateString() { return default(string); }
+ public virtual string GetExpirationDateString() { return default(string); }
public virtual string GetFormat() { return default(string); }
public override int GetHashCode() { return default(int); }
+ [System.ObsoleteAttribute("This method has been deprecated. Please use the Issuer property instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public virtual string GetIssuerName() { return default(string); }
public virtual string GetKeyAlgorithm() { return default(string); }
public virtual byte[] GetKeyAlgorithmParameters() { return default(byte[]); }
public virtual string GetKeyAlgorithmParametersString() { return default(string); }
+ [System.ObsoleteAttribute("This method has been deprecated. Please use the Subject property instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public virtual string GetName() { return default(string); }
public virtual byte[] GetPublicKey() { return default(byte[]); }
+ public virtual string GetPublicKeyString() { return default(string); }
+ public virtual byte[] GetRawCertData() { return default(byte[]); }
+ public virtual string GetRawCertDataString() { return default(string); }
public virtual byte[] GetSerialNumber() { return default(byte[]); }
+ public virtual string GetSerialNumberString() { return default(string); }
public override string ToString() { return default(string); }
public virtual string ToString(bool fVerbose) { return default(string); }
}
@@ -131,6 +144,7 @@ public X509Certificate2(byte[] rawData) { }
public X509Certificate2(byte[] rawData, string password) { }
public X509Certificate2(byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { }
public X509Certificate2(System.IntPtr handle) { }
+ public X509Certificate2(System.Security.Cryptography.X509Certificates.X509Certificate cert) { }
public X509Certificate2(string fileName) { }
public X509Certificate2(string fileName, string password) { }
public X509Certificate2(string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags) { }
@@ -188,15 +202,22 @@ public void Reset() { }
bool System.Collections.IEnumerator.MoveNext() { return default(bool); }
void System.Collections.IEnumerator.Reset() { }
}
- public partial class X509CertificateCollection
+ public partial class X509CertificateCollection : System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
{
public X509CertificateCollection() { }
public X509CertificateCollection(System.Security.Cryptography.X509Certificates.X509Certificate[] value) { }
public X509CertificateCollection(System.Security.Cryptography.X509Certificates.X509CertificateCollection value) { }
+ public int Count { get { return default(int); } }
public System.Security.Cryptography.X509Certificates.X509Certificate this[int index] { get { return default(System.Security.Cryptography.X509Certificates.X509Certificate); } set { } }
+ bool System.Collections.ICollection.IsSynchronized { get { return default(bool); } }
+ object System.Collections.ICollection.SyncRoot { get { return default(object); } }
+ bool System.Collections.IList.IsFixedSize { get { return default(bool); } }
+ bool System.Collections.IList.IsReadOnly { get { return default(bool); } }
+ object System.Collections.IList.this[int index] { get { return default(object); } set { } }
public int Add(System.Security.Cryptography.X509Certificates.X509Certificate value) { return default(int); }
public void AddRange(System.Security.Cryptography.X509Certificates.X509Certificate[] value) { }
public void AddRange(System.Security.Cryptography.X509Certificates.X509CertificateCollection value) { }
+ public void Clear() { }
public bool Contains(System.Security.Cryptography.X509Certificates.X509Certificate value) { return default(bool); }
public void CopyTo(System.Security.Cryptography.X509Certificates.X509Certificate[] array, int index) { }
public System.Security.Cryptography.X509Certificates.X509CertificateCollection.X509CertificateEnumerator GetEnumerator() { return default(System.Security.Cryptography.X509Certificates.X509CertificateCollection.X509CertificateEnumerator); }
@@ -204,6 +225,14 @@ public void CopyTo(System.Security.Cryptography.X509Certificates.X509Certificate
public int IndexOf(System.Security.Cryptography.X509Certificates.X509Certificate value) { return default(int); }
public void Insert(int index, System.Security.Cryptography.X509Certificates.X509Certificate value) { }
public void Remove(System.Security.Cryptography.X509Certificates.X509Certificate value) { }
+ public void RemoveAt(int index) { }
+ void System.Collections.ICollection.CopyTo(System.Array array, int index) { }
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return default(System.Collections.IEnumerator); }
+ int System.Collections.IList.Add(object value) { return default(int); }
+ bool System.Collections.IList.Contains(object value) { return default(bool); }
+ int System.Collections.IList.IndexOf(object value) { return default(int); }
+ void System.Collections.IList.Insert(int index, object value) { }
+ void System.Collections.IList.Remove(object value) { }
public partial class X509CertificateEnumerator : System.Collections.IEnumerator
{
public X509CertificateEnumerator(System.Security.Cryptography.X509Certificates.X509CertificateCollection mappings) { }
@@ -370,6 +399,13 @@ public enum X509FindType
FindByTimeNotYetValid = 7,
FindByTimeValid = 6,
}
+ public enum X509IncludeOption
+ {
+ EndCertOnly = 2,
+ ExcludeRoot = 1,
+ None = 0,
+ WholeChain = 3,
+ }
[System.FlagsAttribute]
public enum X509KeyStorageFlags
{
diff --git a/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.csproj b/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.csproj
index 1feffbdd6b25..9631167ea71f 100644
--- a/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.csproj
+++ b/src/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.csproj
@@ -3,11 +3,10 @@
Library
- .NETStandard,Version=v1.4
+ .NETStandard,Version=v1.7
-
diff --git a/src/System.Security.Cryptography.X509Certificates/ref/project.json b/src/System.Security.Cryptography.X509Certificates/ref/project.json
index b725abe2ab20..0bb10790cc8c 100644
--- a/src/System.Security.Cryptography.X509Certificates/ref/project.json
+++ b/src/System.Security.Cryptography.X509Certificates/ref/project.json
@@ -1,16 +1,14 @@
{
"dependencies": {
- "System.IO": "4.0.0",
- "System.Runtime": "4.0.0",
- "System.Runtime.Handles": "4.0.0",
- "System.Security.Cryptography.Primitives": "4.0.0",
- "System.Security.Cryptography.Algorithms": "4.2.0",
- "System.Security.Cryptography.Encoding": "4.0.0"
+ "System.Runtime": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Algorithms": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Encoding": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Primitives": "4.3.0-beta-24604-02"
},
"frameworks": {
- "netstandard1.4": {
+ "netstandard1.7": {
"imports": [
- "dotnet5.5"
+ "dotnet5.8"
]
}
}
diff --git a/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/CertificatePal.cs b/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/CertificatePal.cs
index a26d5dc748c4..0cc3215bc1e6 100644
--- a/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/CertificatePal.cs
+++ b/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/CertificatePal.cs
@@ -20,6 +20,15 @@ public static ICertificatePal FromHandle(IntPtr handle)
return new OpenSslX509CertificateReader(Interop.Crypto.X509UpRef(handle));
}
+ public static ICertificatePal FromOtherCert(X509Certificate cert)
+ {
+ Debug.Assert(cert.Pal != null);
+
+ // Ensure private key is copied
+ OpenSslX509CertificateReader certPal = (OpenSslX509CertificateReader)cert.Pal;
+ return certPal.DuplicateHandles();
+ }
+
public static ICertificatePal FromBlob(byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
{
ICertificatePal cert;
diff --git a/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.PrivateKey.cs b/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.PrivateKey.cs
index 92087252ae3e..32453a143044 100644
--- a/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.PrivateKey.cs
+++ b/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.PrivateKey.cs
@@ -117,6 +117,7 @@ private static SafeNCryptKeyHandle TryAcquireCngPrivateKey(SafeCertContextHandle
out keySpec,
out freeKey))
{
+ int dwErrorCode = Marshal.GetLastWin32Error();
return null;
}
diff --git a/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs b/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs
index 94f1b6c07a9c..aaff86a3bace 100644
--- a/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs
+++ b/src/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs
@@ -39,6 +39,23 @@ public static ICertificatePal FromHandle(IntPtr handle)
return new CertificatePal(safeCertContextHandle, deleteKeyContainer);
}
+ ///
+ /// Returns the SafeCertContextHandle. Use this instead of FromHandle property when
+ /// creating another X509Certificate object based on this one to ensure the underlying
+ /// cert context is not released at the wrong time.
+ ///
+ ///
+ ///
+ public static ICertificatePal FromOtherCert(X509Certificate cert)
+ {
+ CertificatePal newCert = (CertificatePal)FromHandle(cert.Handle);
+ newCert._certContextCloned = true;
+
+ ((CertificatePal)cert.Pal)._certContextCloned = true;
+
+ return newCert;
+ }
+
public IntPtr Handle
{
get { return _certContext.DangerousGetHandle(); }
@@ -471,7 +488,10 @@ public void Dispose()
_certContext = null;
if (certContext != null && !certContext.IsInvalid)
{
- certContext.Dispose();
+ if (!_certContextCloned)
+ {
+ certContext.Dispose();
+ }
}
}
@@ -541,5 +561,6 @@ private CertificatePal(SafeCertContextHandle certContext, bool deleteKeyContaine
}
private SafeCertContextHandle _certContext;
+ private bool _certContextCloned;
}
}
diff --git a/src/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.builds b/src/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.builds
index c14579096c98..58091c1e2811 100644
--- a/src/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.builds
+++ b/src/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.builds
@@ -10,15 +10,7 @@
Windows_NT
- netcore50
-
-
- Windows_NT
- net46
-
-
- Windows_NT
- net461
+ net463
diff --git a/src/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj b/src/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj
index a9fdfe615a21..0059a9ca9989 100644
--- a/src/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj
+++ b/src/System.Security.Cryptography.X509Certificates/src/System.Security.Cryptography.X509Certificates.csproj
@@ -10,14 +10,9 @@
{6F8576C2-6CD0-4DF3-8394-00B002D82E40}
Library
System.Security.Cryptography.X509Certificates
- 4.0.0.0
true
- true
- .NETStandard,Version=v1.6
-
-
- netcore50/project.json
- netcore50/project.lock.json
+ true
+ .NETStandard,Version=v1.7
win/project.json
@@ -31,11 +26,6 @@
-
-
-
- $(DefineConstants);NETNATIVE
-
@@ -81,6 +71,7 @@
+
@@ -93,7 +84,6 @@
-
diff --git a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/DSACryptoServiceProviderStub.cs b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/DSACryptoServiceProviderStub.cs
deleted file mode 100644
index b0bd55452da3..000000000000
--- a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/DSACryptoServiceProviderStub.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System;
-using System.Diagnostics;
-
-namespace System.Security.Cryptography
-{
-#if !NETNATIVE
- ///
- /// @todo: This is a stub DSACryptoServiceProvider that allows the rest of the X509 code to compile. Once the DSACryptoServiceProvider contract has been
- /// brought up, delete this file and add a reference to the DSA contract to the X509 .csproj file.
- ///
- internal sealed class DSACryptoServiceProvider : AsymmetricAlgorithm, ICspAsymmetricAlgorithm
- {
- public DSACryptoServiceProvider()
- {
- }
-
- public DSACryptoServiceProvider(CspParameters cspParameters)
- {
- throw new NotImplementedException("DSACryptoServiceProvider is not supported on this platform at this time.");
- }
-
- public void ImportCspBlob(byte[] cspBlob)
- {
- _cspBlob = (byte[])cspBlob.Clone();
- }
-
- public CspKeyContainerInfo CspKeyContainerInfo
- {
- get { throw new NotImplementedException("DSACryptoServiceProvider is not supported on this platform at this time."); }
- }
-
- public byte[] ExportCspBlob(bool includePrivateParameters)
- {
- return (byte[])(_cspBlob.Clone());
- }
-
- private byte[] _cspBlob;
- }
-#endif
-}
-
diff --git a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs
index 6ae192969758..bc948a807fd6 100644
--- a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs
+++ b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs
@@ -2,15 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.IO;
-using System.Text;
-using System.Diagnostics;
-using System.Globalization;
-using System.Runtime.InteropServices;
-
using Internal.Cryptography;
using Internal.Cryptography.Pal;
+using System.Diagnostics;
+using System.Globalization;
+using System.Text;
namespace System.Security.Cryptography.X509Certificates
{
@@ -72,6 +68,17 @@ public X509Certificate(string fileName, string password, X509KeyStorageFlags key
Pal = CertificatePal.FromFile(fileName, password, keyStorageFlags);
}
+ public X509Certificate(X509Certificate cert)
+ {
+ if (cert == null)
+ throw new ArgumentNullException(nameof(cert));
+
+ if (cert.Pal != null)
+ {
+ Pal = CertificatePal.FromOtherCert(cert);
+ }
+ }
+
public IntPtr Handle
{
get
@@ -177,23 +184,57 @@ public virtual byte[] Export(X509ContentType contentType, string password)
}
}
+ public virtual string GetRawCertDataString()
+ {
+ ThrowIfInvalid();
+ return GetRawCertData().ToHexStringUpper();
+ }
+
public virtual byte[] GetCertHash()
{
ThrowIfInvalid();
return GetRawCertHash().CloneByteArray();
}
+ public virtual string GetCertHashString()
+ {
+ ThrowIfInvalid();
+ return GetRawCertHash().ToHexStringUpper();
+ }
+
// Only use for internal purposes when the returned byte[] will not be mutated
private byte[] GetRawCertHash()
{
return _lazyCertHash ?? (_lazyCertHash = Pal.Thumbprint);
}
+ public virtual string GetEffectiveDateString()
+ {
+ return GetNotBefore().ToString();
+ }
+
+ public virtual string GetExpirationDateString()
+ {
+ return GetNotAfter().ToString();
+ }
+
public virtual string GetFormat()
{
return "X509";
}
+ public virtual string GetPublicKeyString()
+ {
+ return GetPublicKey().ToHexStringUpper();
+ }
+
+ public virtual byte[] GetRawCertData()
+ {
+ ThrowIfInvalid();
+
+ return Pal.RawData.CloneByteArray();
+ }
+
public override int GetHashCode()
{
if (Pal == null)
@@ -253,12 +294,31 @@ public virtual byte[] GetSerialNumber()
return GetRawSerialNumber().CloneByteArray();
}
+ public virtual string GetSerialNumberString()
+ {
+ ThrowIfInvalid();
+
+ return GetRawSerialNumber().ToHexStringUpper();
+ }
+
// Only use for internal purposes when the returned byte[] will not be mutated
private byte[] GetRawSerialNumber()
{
return _lazySerialNumber ?? (_lazySerialNumber = Pal.SerialNumber);
}
+ [Obsolete("This method has been deprecated. Please use the Subject property instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public virtual string GetName()
+ {
+ return Subject;
+ }
+
+ [Obsolete("This method has been deprecated. Please use the Issuer property instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public virtual string GetIssuerName()
+ {
+ return Issuer;
+ }
+
public override string ToString()
{
return ToString(fVerbose: false);
diff --git a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs
index a2e2055fd2cb..3fe0a919fc2d 100644
--- a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs
+++ b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs
@@ -2,15 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.IO;
-using System.Text;
-using System.Diagnostics;
-using System.Globalization;
-using System.Runtime.InteropServices;
-
using Internal.Cryptography;
using Internal.Cryptography.Pal;
+using System.IO;
+using System.Text;
namespace System.Security.Cryptography.X509Certificates
{
@@ -61,6 +56,11 @@ public X509Certificate2(string fileName, string password, X509KeyStorageFlags ke
{
}
+ public X509Certificate2(X509Certificate cert)
+ : base(cert)
+ {
+ }
+
public bool Archived
{
get
diff --git a/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509IncludeOption.cs b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509IncludeOption.cs
new file mode 100644
index 000000000000..b94903c4440a
--- /dev/null
+++ b/src/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509IncludeOption.cs
@@ -0,0 +1,14 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Security.Cryptography.X509Certificates
+{
+ public enum X509IncludeOption
+ {
+ None = 0,
+ ExcludeRoot,
+ EndCertOnly,
+ WholeChain
+ }
+}
diff --git a/src/System.Security.Cryptography.X509Certificates/src/facade/project.json b/src/System.Security.Cryptography.X509Certificates/src/facade/project.json
deleted file mode 100644
index 0c1b78a246a1..000000000000
--- a/src/System.Security.Cryptography.X509Certificates/src/facade/project.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "frameworks": {
- "net46": {
- "dependencies": {
- "Microsoft.TargetingPack.NETFramework.v4.6": "1.0.1"
- }
- }
- }
-}
diff --git a/src/System.Security.Cryptography.X509Certificates/src/project.json b/src/System.Security.Cryptography.X509Certificates/src/project.json
index 1abb1d015643..c17e5786fb94 100644
--- a/src/System.Security.Cryptography.X509Certificates/src/project.json
+++ b/src/System.Security.Cryptography.X509Certificates/src/project.json
@@ -1,13 +1,17 @@
{
"frameworks": {
- "net46": {
+ "netstandard1.7": {
"dependencies": {
- "Microsoft.TargetingPack.NETFramework.v4.6": "1.0.1"
- }
+ "Microsoft.NETCore.Platforms": "1.0.1",
+ "Microsoft.TargetingPack.Private.CoreCLR": "1.2.0-beta-24605-01"
+ },
+ "imports": [
+ "dotnet5.8"
+ ]
},
- "net461": {
+ "net463": {
"dependencies": {
- "Microsoft.TargetingPack.NETFramework.v4.6.1": "1.0.1"
+ "Microsoft.TargetingPack.NETFramework.v4.6.2": "1.0.1"
}
}
}
diff --git a/src/System.Security.Cryptography.X509Certificates/src/unix/project.json b/src/System.Security.Cryptography.X509Certificates/src/unix/project.json
index 9e0ba67e4c7d..c19b5fda7c64 100644
--- a/src/System.Security.Cryptography.X509Certificates/src/unix/project.json
+++ b/src/System.Security.Cryptography.X509Certificates/src/unix/project.json
@@ -1,28 +1,30 @@
{
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.2-beta-24604-02",
- "System.Collections": "4.0.10",
- "System.Diagnostics.Contracts": "4.0.0",
- "System.Diagnostics.Debug": "4.0.10",
- "System.Globalization": "4.0.10",
- "System.Globalization.Calendars": "4.0.0",
- "System.IO.FileSystem": "4.0.0",
- "System.Resources.ResourceManager": "4.0.0",
- "System.Runtime": "4.1.0",
- "System.Runtime.Handles": "4.0.0",
- "System.Runtime.InteropServices": "4.0.20",
- "System.Runtime.Numerics": "4.0.0",
- "System.Security.Cryptography.Algorithms": "4.2.0",
- "System.Security.Cryptography.Encoding": "4.0.0",
- "System.Security.Cryptography.OpenSsl": "4.0.0",
- "System.Security.Cryptography.Primitives": "4.0.0",
- "System.Text.Encoding": "4.0.10",
- "System.Threading": "4.0.10"
+ "System.Collections": "4.3.0-beta-24604-02",
+ "System.Diagnostics.Contracts": "4.3.0-beta-24604-02",
+ "System.Diagnostics.Debug": "4.3.0-beta-24604-02",
+ "System.Globalization": "4.3.0-beta-24604-02",
+ "System.Globalization.Calendars": "4.3.0-beta-24604-02",
+ "System.IO.FileSystem": "4.3.0-beta-24604-02",
+ "System.Resources.ResourceManager": "4.3.0-beta-24604-02",
+ "System.Runtime": "4.3.0-beta-24604-02",
+ "System.Runtime.Extensions": "4.3.0-beta-24604-02",
+ "System.Runtime.Handles": "4.3.0-beta-24604-02",
+ "System.Runtime.InteropServices": "4.3.0-beta-24604-02",
+ "System.Runtime.Numerics": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Algorithms": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Encoding": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.OpenSsl": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Primitives": "4.3.0-beta-24604-02",
+ "System.Text.Encoding": "4.3.0-beta-24604-02",
+ "System.Threading": "4.3.0-beta-24604-02",
+ "System.Threading.Tasks": "4.3.0-beta-24604-02"
},
"frameworks": {
- "netstandard1.6": {
+ "netstandard1.7": {
"imports": [
- "dotnet5.5"
+ "dotnet5.8"
]
}
}
diff --git a/src/System.Security.Cryptography.X509Certificates/src/win/project.json b/src/System.Security.Cryptography.X509Certificates/src/win/project.json
index bd95bde459d0..db7f3380a4e8 100644
--- a/src/System.Security.Cryptography.X509Certificates/src/win/project.json
+++ b/src/System.Security.Cryptography.X509Certificates/src/win/project.json
@@ -1,33 +1,33 @@
{
"dependencies": {
"Microsoft.NETCore.Platforms": "1.0.2-beta-24604-02",
- "System.Collections": "4.0.10",
- "System.Diagnostics.Contracts": "4.0.0",
- "System.Diagnostics.Debug": "4.0.10",
- "System.Globalization": "4.0.10",
- "System.Globalization.Calendars": "4.0.0",
- "System.IO.FileSystem": "4.0.0",
- "System.IO.FileSystem.Watcher": "4.0.0",
- "System.Resources.ResourceManager": "4.0.0",
- "System.Runtime": "4.1.0",
- "System.Runtime.Handles": "4.0.0",
- "System.Runtime.InteropServices": "4.0.20",
- "System.Runtime.Numerics": "4.0.0",
- "System.Security.Cryptography.Algorithms": "4.2.0",
- "System.Security.Cryptography.Cng": "4.2.0",
- "System.Security.Cryptography.Encoding": "4.0.0",
- "System.Security.Cryptography.Primitives": "4.0.0",
- "System.Text.Encoding": "4.0.10",
- "System.Threading": "4.0.10"
+ "System.Collections": "4.3.0-beta-24604-02",
+ "System.Diagnostics.Contracts": "4.3.0-beta-24604-02",
+ "System.Diagnostics.Debug": "4.3.0-beta-24604-02",
+ "System.Globalization": "4.3.0-beta-24604-02",
+ "System.Globalization.Calendars": "4.3.0-beta-24604-02",
+ "System.IO.FileSystem": "4.3.0-beta-24604-02",
+ "System.IO.FileSystem.Watcher": "4.3.0-beta-24604-02",
+ "System.Resources.ResourceManager": "4.3.0-beta-24604-02",
+ "System.Runtime": "4.3.0-beta-24604-02",
+ "System.Runtime.Extensions": "4.3.0-beta-24604-02",
+ "System.Runtime.Handles": "4.3.0-beta-24604-02",
+ "System.Runtime.InteropServices": "4.3.0-beta-24604-02",
+ "System.Runtime.Numerics": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Algorithms": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Cng": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Csp": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Encoding": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Primitives": "4.3.0-beta-24604-02",
+ "System.Text.Encoding": "4.3.0-beta-24604-02",
+ "System.Threading": "4.3.0-beta-24604-02",
+ "System.Threading.Tasks": "4.3.0-beta-24604-02"
},
"frameworks": {
- "netstandard1.6": {
+ "netstandard1.7": {
"imports": [
- "dotnet5.5"
- ],
- "dependencies": {
- "System.Security.Cryptography.Csp": "4.0.0"
- }
+ "dotnet5.8"
+ ]
}
}
}
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/CertTests.cs b/src/System.Security.Cryptography.X509Certificates/tests/CertTests.cs
index b73157f1febe..5bdeb8196db5 100644
--- a/src/System.Security.Cryptography.X509Certificates/tests/CertTests.cs
+++ b/src/System.Security.Cryptography.X509Certificates/tests/CertTests.cs
@@ -67,6 +67,10 @@ public static void X509Cert2Test()
Assert.Equal(notAfter, cert2.NotAfter);
Assert.Equal(notBefore, cert2.NotBefore);
+#if netstandard17
+ Assert.Equal(notAfter.ToString(), cert2.GetExpirationDateString());
+ Assert.Equal(notBefore.ToString(), cert2.GetEffectiveDateString());
+#endif
Assert.Equal("00D01E4090000046520000000100000004", cert2.SerialNumber);
Assert.Equal("1.2.840.113549.1.1.5", cert2.SignatureAlgorithm.Value);
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/CtorTests.cs b/src/System.Security.Cryptography.X509Certificates/tests/CtorTests.cs
index b163d5cfb99f..da2869dd1e3c 100644
--- a/src/System.Security.Cryptography.X509Certificates/tests/CtorTests.cs
+++ b/src/System.Security.Cryptography.X509Certificates/tests/CtorTests.cs
@@ -14,32 +14,50 @@ public static void TestDefaultConstructor()
{
using (X509Certificate2 c = new X509Certificate2())
{
- IntPtr h = c.Handle;
- object ignored;
- Assert.Equal(IntPtr.Zero, h);
- Assert.ThrowsAny(() => c.GetCertHash());
- Assert.ThrowsAny(() => c.GetKeyAlgorithm());
- Assert.ThrowsAny(() => c.GetKeyAlgorithmParameters());
- Assert.ThrowsAny(() => c.GetKeyAlgorithmParametersString());
- Assert.ThrowsAny(() => c.GetPublicKey());
- Assert.ThrowsAny(() => c.GetSerialNumber());
- Assert.ThrowsAny(() => ignored = c.Issuer);
- Assert.ThrowsAny(() => ignored = c.Subject);
- Assert.ThrowsAny(() => ignored = c.RawData);
- Assert.ThrowsAny(() => ignored = c.Thumbprint);
- Assert.ThrowsAny(() => ignored = c.SignatureAlgorithm);
- Assert.ThrowsAny(() => ignored = c.HasPrivateKey);
- Assert.ThrowsAny(() => ignored = c.Version);
- Assert.ThrowsAny(() => ignored = c.Archived);
- Assert.ThrowsAny(() => c.Archived = false);
- Assert.ThrowsAny(() => c.FriendlyName = "Hi");
- Assert.ThrowsAny(() => ignored = c.SubjectName);
- Assert.ThrowsAny(() => ignored = c.IssuerName);
+ VerifyDefaultConstructor(c);
}
}
+ private static void VerifyDefaultConstructor(X509Certificate2 c)
+ {
+ IntPtr h = c.Handle;
+ object ignored;
+ Assert.Equal(IntPtr.Zero, h);
+ Assert.ThrowsAny(() => c.GetCertHash());
+ Assert.ThrowsAny(() => c.GetKeyAlgorithm());
+ Assert.ThrowsAny(() => c.GetKeyAlgorithmParameters());
+ Assert.ThrowsAny(() => c.GetKeyAlgorithmParametersString());
+ Assert.ThrowsAny(() => c.GetPublicKey());
+ Assert.ThrowsAny(() => c.GetSerialNumber());
+ Assert.ThrowsAny(() => ignored = c.Issuer);
+ Assert.ThrowsAny(() => ignored = c.Subject);
+ Assert.ThrowsAny(() => ignored = c.RawData);
+ Assert.ThrowsAny(() => ignored = c.Thumbprint);
+ Assert.ThrowsAny(() => ignored = c.SignatureAlgorithm);
+ Assert.ThrowsAny(() => ignored = c.HasPrivateKey);
+ Assert.ThrowsAny(() => ignored = c.Version);
+ Assert.ThrowsAny(() => ignored = c.Archived);
+ Assert.ThrowsAny(() => c.Archived = false);
+ Assert.ThrowsAny(() => c.FriendlyName = "Hi");
+ Assert.ThrowsAny(() => ignored = c.SubjectName);
+ Assert.ThrowsAny(() => ignored = c.IssuerName);
+#if netstandard17
+ Assert.ThrowsAny(() => c.GetCertHashString());
+ Assert.ThrowsAny(() => c.GetEffectiveDateString());
+ Assert.ThrowsAny(() => c.GetExpirationDateString());
+ Assert.ThrowsAny(() => c.GetPublicKeyString());
+ Assert.ThrowsAny(() => c.GetRawCertData());
+ Assert.ThrowsAny(() => c.GetRawCertDataString());
+ Assert.ThrowsAny(() => c.GetSerialNumberString());
+#pragma warning disable 0618
+ Assert.ThrowsAny(() => c.GetIssuerName());
+ Assert.ThrowsAny(() => c.GetName());
+#pragma warning restore 0618
+#endif
+ }
+
[Fact]
- public static void TestByteArrayConstructor_DER()
+ public static void TestConstructor_DER()
{
byte[] expectedThumbPrint = new byte[]
{
@@ -48,17 +66,28 @@ public static void TestByteArrayConstructor_DER()
0xc3, 0x13, 0x87, 0xfe,
};
- using (X509Certificate2 c = new X509Certificate2(TestData.MsCertificate))
+ Action assert = (c) =>
{
IntPtr h = c.Handle;
Assert.NotEqual(IntPtr.Zero, h);
byte[] actualThumbprint = c.GetCertHash();
Assert.Equal(expectedThumbPrint, actualThumbprint);
+ };
+
+ using (X509Certificate2 c = new X509Certificate2(TestData.MsCertificate))
+ {
+ assert(c);
+#if netstandard17
+ using (X509Certificate2 c2 = new X509Certificate2(c))
+ {
+ assert(c2);
+ }
+#endif
}
}
[Fact]
- public static void TestByteArrayConstructor_PEM()
+ public static void TestConstructor_PEM()
{
byte[] expectedThumbPrint =
{
@@ -67,26 +96,170 @@ public static void TestByteArrayConstructor_PEM()
0xc3, 0x13, 0x87, 0xfe,
};
- using (X509Certificate2 cert = new X509Certificate2(TestData.MsCertificatePemBytes))
+ Action assert = (cert) =>
{
IntPtr h = cert.Handle;
Assert.NotEqual(IntPtr.Zero, h);
byte[] actualThumbprint = cert.GetCertHash();
Assert.Equal(expectedThumbPrint, actualThumbprint);
+ };
+
+ using (X509Certificate2 c = new X509Certificate2(TestData.MsCertificatePemBytes))
+ {
+ assert(c);
+#if netstandard17
+ using (X509Certificate2 c2 = new X509Certificate2(c))
+ {
+ assert(c2);
+ }
+#endif
+ }
+ }
+
+#if netstandard17
+ [Fact]
+ public static void TestCopyConstructor_NoPal()
+ {
+ using (var c1 = new X509Certificate2())
+ using (var c2 = new X509Certificate2(c1))
+ {
+ VerifyDefaultConstructor(c1);
+ VerifyDefaultConstructor(c2);
+ }
+ }
+
+ [Fact]
+ public static void TestCopyConstructor_Pal()
+ {
+ using (var c1 = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword))
+ using (var c2 = new X509Certificate2(c1))
+ {
+ Assert.Equal(c1.GetCertHash(), c2.GetCertHash());
+ Assert.Equal(c1.GetKeyAlgorithm(), c2.GetKeyAlgorithm());
+ Assert.Equal(c1.GetKeyAlgorithmParameters(), c2.GetKeyAlgorithmParameters());
+ Assert.Equal(c1.GetKeyAlgorithmParametersString(), c2.GetKeyAlgorithmParametersString());
+ Assert.Equal(c1.GetPublicKey(), c2.GetPublicKey());
+ Assert.Equal(c1.GetSerialNumber(), c2.GetSerialNumber());
+ Assert.Equal(c1.Issuer, c2.Issuer);
+ Assert.Equal(c1.Subject, c2.Subject);
+ Assert.Equal(c1.RawData, c2.RawData);
+ Assert.Equal(c1.Thumbprint, c2.Thumbprint);
+ Assert.Equal(c1.SignatureAlgorithm.Value, c2.SignatureAlgorithm.Value);
+ Assert.Equal(c1.HasPrivateKey, c2.HasPrivateKey);
+ Assert.Equal(c1.Version, c2.Version);
+ Assert.Equal(c1.Archived, c2.Archived);
+ Assert.Equal(c1.SubjectName.Name, c2.SubjectName.Name);
+ Assert.Equal(c1.IssuerName.Name, c2.IssuerName.Name);
+ Assert.Equal(c1.GetCertHashString(), c2.GetCertHashString());
+ Assert.Equal(c1.GetEffectiveDateString(), c2.GetEffectiveDateString());
+ Assert.Equal(c1.GetExpirationDateString(), c2.GetExpirationDateString());
+ Assert.Equal(c1.GetPublicKeyString(), c2.GetPublicKeyString());
+ Assert.Equal(c1.GetRawCertData(), c2.GetRawCertData());
+ Assert.Equal(c1.GetRawCertDataString(), c2.GetRawCertDataString());
+ Assert.Equal(c1.GetSerialNumberString(), c2.GetSerialNumberString());
+#pragma warning disable 0618
+ Assert.Equal(c1.GetIssuerName(), c2.GetIssuerName());
+ Assert.Equal(c1.GetName(), c2.GetName());
+#pragma warning restore 0618
+ }
+ }
+
+ [Fact]
+ public static void TestCopyConstructor_Lifetime_Independent()
+ {
+ var c1 = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword);
+ using (var c2 = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword))
+ {
+ RSA rsa = c2.GetRSAPrivateKey();
+ byte[] hash = new byte[20];
+ byte[] sig = rsa.SignHash(hash, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
+ Assert.Equal(TestData.PfxSha1Empty_ExpectedSig, sig);
+
+ c1.Dispose();
+ rsa.Dispose();
+
+ // Verify other cert and previous key do not affect cert
+ using (rsa = c2.GetRSAPrivateKey())
+ {
+ hash = new byte[20];
+ sig = rsa.SignHash(hash, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
+ Assert.Equal(TestData.PfxSha1Empty_ExpectedSig, sig);
+ }
+ }
+ }
+
+ [Fact]
+ public static void TestCopyConstructor_Lifetime_Cloned()
+ {
+ var c1 = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword);
+ var c2 = new X509Certificate2(c1);
+ TestPrivateKey(c1, true);
+ TestPrivateKey(c2, true);
+
+ c1.Dispose();
+ TestPrivateKey(c1, false);
+ TestPrivateKey(c2, true);
+
+ c2.Dispose();
+ TestPrivateKey(c2, false);
+ }
+
+ [Fact]
+ public static void TestCopyConstructor_Lifetime_Cloned_Reversed()
+ {
+ var c1 = new X509Certificate2(TestData.PfxData, TestData.PfxDataPassword);
+ var c2 = new X509Certificate2(c1);
+ TestPrivateKey(c1, true);
+ TestPrivateKey(c2, true);
+
+ c2.Dispose();
+ TestPrivateKey(c1, true);
+ TestPrivateKey(c2, false);
+
+ c1.Dispose();
+ TestPrivateKey(c1, false);
+ }
+
+ private static void TestPrivateKey(X509Certificate2 c, bool expectSuccess)
+ {
+ if (expectSuccess)
+ {
+ using (RSA rsa = c.GetRSAPrivateKey())
+ {
+ byte[] hash = new byte[20];
+ byte[] sig = rsa.SignHash(hash, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
+ Assert.Equal(TestData.PfxSha1Empty_ExpectedSig, sig);
+ }
+ }
+ else
+ {
+ Assert.ThrowsAny(() => c.GetRSAPrivateKey());
}
}
+#endif
[Fact]
[PlatformSpecific(TestPlatforms.Windows)]
- public static void TestByteArrayConstructor_SerializedCert_Windows()
+ public static void TestConstructor_SerializedCert_Windows()
{
const string ExpectedThumbPrint = "71CB4E2B02738AD44F8B382C93BD17BA665F9914";
- using (X509Certificate2 cert = new X509Certificate2(TestData.StoreSavedAsSerializedCerData))
+ Action assert = (cert) =>
{
IntPtr h = cert.Handle;
Assert.NotEqual(IntPtr.Zero, h);
Assert.Equal(ExpectedThumbPrint, cert.Thumbprint);
+ };
+
+ using (X509Certificate2 c = new X509Certificate2(TestData.StoreSavedAsSerializedCerData))
+ {
+ assert(c);
+#if netstandard17
+ using (X509Certificate2 c2 = new X509Certificate2(c))
+ {
+ assert(c2);
+ }
+#endif
}
}
@@ -104,6 +277,9 @@ public static void TestNullConstructorArguments()
Assert.Throws(() => new X509Certificate2(new byte[0], (String)null));
Assert.Throws(() => new X509Certificate2((byte[])null, (String)null, X509KeyStorageFlags.DefaultKeySet));
Assert.Throws(() => new X509Certificate2(new byte[0], (String)null, X509KeyStorageFlags.DefaultKeySet));
+#if netstandard17
+ Assert.Throws(() => new X509Certificate2((X509Certificate2)null));
+#endif
// For compat reasons, the (byte[]) constructor (and only that constructor) treats a null or 0-length array as the same
// as calling the default constructor.
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/InteropTests.cs b/src/System.Security.Cryptography.X509Certificates/tests/InteropTests.cs
index 9cfaacde0d6d..93173df22319 100644
--- a/src/System.Security.Cryptography.X509Certificates/tests/InteropTests.cs
+++ b/src/System.Security.Cryptography.X509Certificates/tests/InteropTests.cs
@@ -46,9 +46,9 @@ public static void TestHandle()
public static void TestHandleCtor()
{
IntPtr pCertContext = IntPtr.Zero;
+ byte[] rawData = TestData.MsCertificate;
unsafe
{
- byte[] rawData = TestData.MsCertificate;
fixed (byte* pRawData = rawData)
{
CRYPTOAPI_BLOB certBlob = new CRYPTOAPI_BLOB() { cbData = rawData.Length, pbData = pRawData };
@@ -85,6 +85,11 @@ out pCertContext
Assert.Equal(pCertContext, h);
pCertContext = IntPtr.Zero;
+#if netstandard17
+ Assert.Equal(rawData, c.GetRawCertData());
+ Assert.Equal(rawData, c.GetRawCertDataString().HexToByteArray());
+#endif
+
string issuer = c.Issuer;
Assert.Equal(
"CN=Microsoft Code Signing PCA, O=Microsoft Corporation, L=Redmond, S=Washington, C=US",
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/LoadFromFileTests.cs b/src/System.Security.Cryptography.X509Certificates/tests/LoadFromFileTests.cs
index 9b05b8ae7d15..1793f373ff3b 100644
--- a/src/System.Security.Cryptography.X509Certificates/tests/LoadFromFileTests.cs
+++ b/src/System.Security.Cryptography.X509Certificates/tests/LoadFromFileTests.cs
@@ -39,24 +39,34 @@ public static void TestSubject()
[Fact]
public static void TestSerial()
{
- byte[] expectedSerial = "b00000000100dd9f3bd08b0aaf11b000000033".HexToByteArray();
+ string expectedSerialHex = "B00000000100DD9F3BD08B0AAF11B000000033";
+ byte[] expectedSerial = expectedSerialHex.HexToByteArray();
using (X509Certificate2 c = LoadCertificateFromFile())
{
byte[] serial = c.GetSerialNumber();
Assert.Equal(expectedSerial, serial);
+#if netstandard17
+ string serialHex = c.GetSerialNumberString();
+ Assert.Equal(expectedSerialHex, serialHex);
+#endif
}
}
[Fact]
public static void TestThumbprint()
{
- byte[] expectedThumbPrint = "108e2ba23632620c427c570b6d9db51ac31387fe".HexToByteArray();
+ string expectedThumbPrintHex = "108E2BA23632620C427C570B6D9DB51AC31387FE";
+ byte[] expectedThumbPrint = expectedThumbPrintHex.HexToByteArray();
using (X509Certificate2 c = LoadCertificateFromFile())
{
byte[] thumbPrint = c.GetCertHash();
Assert.Equal(expectedThumbPrint, thumbPrint);
+#if netstandard17
+ string thumbPrintHex = c.GetCertHashString();
+ Assert.Equal(expectedThumbPrintHex, thumbPrintHex);
+#endif
}
}
@@ -97,7 +107,7 @@ public static void TestGetKeyAlgorithmParameters()
[Fact]
public static void TestGetPublicKey()
{
- byte[] expectedPublicKey = (
+ string expectedPublicKeyHex =
"3082010a0282010100e8af5ca2200df8287cbc057b7fadeeeb76ac28533f3adb" +
"407db38e33e6573fa551153454a5cfb48ba93fa837e12d50ed35164eef4d7adb" +
"137688b02cf0595ca9ebe1d72975e41b85279bf3f82d9e41362b0b40fbbe3bba" +
@@ -106,12 +116,17 @@ public static void TestGetPublicKey()
"2f826a8103f5a935dc94579dfb4bd40e82db388f12fee3d67a748864e162c425" +
"2e2aae9d181f0e1eb6c2af24b40e50bcde1c935c49a679b5b6dbcef9707b2801" +
"84b82a29cfbfa90505e1e00f714dfdad5c238329ebc7c54ac8e82784d37ec643" +
- "0b950005b14f6571c50203010001").HexToByteArray();
+ "0b950005b14f6571c50203010001";
+ byte[] expectedPublicKey = expectedPublicKeyHex.HexToByteArray();
using (X509Certificate2 c = LoadCertificateFromFile())
{
byte[] publicKey = c.GetPublicKey();
Assert.Equal(expectedPublicKey, publicKey);
+#if netstandard17
+ string publicKeyHex = c.GetPublicKeyString();
+ Assert.Equal(expectedPublicKeyHex, publicKeyHex, true);
+#endif
}
}
@@ -132,15 +147,30 @@ public static void TestLoadSignedFile()
Assert.Equal(
"CN=Microsoft Code Signing PCA, O=Microsoft Corporation, L=Redmond, S=Washington, C=US",
issuer);
+#if netstandard17
+#pragma warning disable 0618
+ Assert.Equal(c.Issuer, c.GetIssuerName());
+#pragma warning restore 0618
+#endif
string subject = c.Subject;
Assert.Equal(
"CN=Microsoft Corporation, OU=MOPR, O=Microsoft Corporation, L=Redmond, S=Washington, C=US",
subject);
-
- byte[] expectedThumbprint = "67b1757863e3eff760ea9ebb02849af07d3a8080".HexToByteArray();
+#if netstandard17
+#pragma warning disable 0618
+ Assert.Equal(subject, c.GetName());
+#pragma warning restore 0618
+#endif
+
+ string expectedThumbprintHash = "67B1757863E3EFF760EA9EBB02849AF07D3A8080";
+ byte[] expectedThumbprint = expectedThumbprintHash.HexToByteArray();
byte[] actualThumbprint = c.GetCertHash();
Assert.Equal(expectedThumbprint, actualThumbprint);
+#if netstandard17
+ string actualThumbprintHash = c.GetCertHashString();
+ Assert.Equal(expectedThumbprintHash, actualThumbprintHash);
+#endif
}
}
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/PfxTests.cs b/src/System.Security.Cryptography.X509Certificates/tests/PfxTests.cs
index 2a6e40e6ae4f..e6ff8d9da107 100644
--- a/src/System.Security.Cryptography.X509Certificates/tests/PfxTests.cs
+++ b/src/System.Security.Cryptography.X509Certificates/tests/PfxTests.cs
@@ -95,7 +95,7 @@ public static void TestPrivateKey()
{
byte[] hash = new byte[20];
byte[] sig = rsa.SignHash(hash, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
- Assert.Equal(s_expectedSig, sig);
+ Assert.Equal(TestData.PfxSha1Empty_ExpectedSig, sig);
}
}
}
@@ -200,10 +200,6 @@ private static void AssertEccAlgorithm(ECDsa ecdsa, string algorithmId)
}
}
- private static readonly byte[] s_expectedSig =
- ("44b15120b8c7de19b4968d761600ffb8c54e5d0c1bcaba0880a20ab48912c8fdfa81b28134eabf58f3211a0d1eefdaae115e7872d5a67045c3b62a5da4393940e5a496"
- + "413a6d55ea6309d0013e90657c83c6e40aa8fafeee66acbb6661c1419011e1fde6f4fcc328bd7e537e4aa2dbe216d8f1f3aa7e5ec60eb9cfdca7a41d74").HexToByteArray();
-
private static X509Certificate2 Rewrap(this X509Certificate2 c)
{
X509Certificate2 newC = new X509Certificate2(c.Handle);
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.builds b/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.builds
index 7a39ece8d7bf..c8c734758c13 100644
--- a/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.builds
+++ b/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.builds
@@ -4,11 +4,21 @@
Unix
+ netstandard1.6
+ netcoreapp1.0
+ Unix
+
+
+ Windows_NT
+ netstandard1.6
+ netcoreapp1.0
+
+
+ netcoreapp1.1;net463
Windows_NT
- netcore50;netcoreapp1.0;net461
-
-
+
+
\ No newline at end of file
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj b/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj
index 4a43f46f29b2..17dcbe8234e6 100644
--- a/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj
+++ b/src/System.Security.Cryptography.X509Certificates/tests/System.Security.Cryptography.X509Certificates.Tests.csproj
@@ -12,7 +12,8 @@
System.Security.Cryptography.X509Certificates.Tests
System.Security.Cryptography.X509Certificates.Tests
true
- .NETStandard,Version=v1.4
+ .NETStandard,Version=v1.7
+ $(DefineConstants);netstandard17
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs b/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs
index 257338d1f5a9..84718755132c 100644
--- a/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs
+++ b/src/System.Security.Cryptography.X509Certificates/tests/TestData.cs
@@ -84,6 +84,12 @@ internal static class TestData
public const string PfxDataPassword = "12345";
+ public static readonly byte[] PfxSha1Empty_ExpectedSig = (
+ "44b15120b8c7de19b4968d761600ffb8c54e5d0c1bcaba0880a20ab48912c8fd" +
+ "fa81b28134eabf58f3211a0d1eefdaae115e7872d5a67045c3b62a5da4393940" +
+ "e5a496413a6d55ea6309d0013e90657c83c6e40aa8fafeee66acbb6661c14190" +
+ "11e1fde6f4fcc328bd7e537e4aa2dbe216d8f1f3aa7e5ec60eb9cfdca7a41d74").HexToByteArray();
+
public static readonly byte[] PfxData = (
"3082063A020103308205F606092A864886F70D010701A08205E7048205E33082" +
"05DF3082035806092A864886F70D010701A08203490482034530820341308203" +
diff --git a/src/System.Security.Cryptography.X509Certificates/tests/project.json b/src/System.Security.Cryptography.X509Certificates/tests/project.json
index ecf1e425e283..80d0af402760 100644
--- a/src/System.Security.Cryptography.X509Certificates/tests/project.json
+++ b/src/System.Security.Cryptography.X509Certificates/tests/project.json
@@ -12,7 +12,9 @@
"System.Runtime.InteropServices.RuntimeInformation": "4.3.0-beta-24604-02",
"System.Security.Cryptography.Algorithms": "4.3.0-beta-24604-02",
"System.Security.Cryptography.Cng": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.Csp": "4.3.0-beta-24604-02",
"System.Security.Cryptography.Encoding": "4.3.0-beta-24604-02",
+ "System.Security.Cryptography.OpenSsl": "4.3.0-beta-24604-02",
"System.Security.Cryptography.X509Certificates.TestData": "1.0.2-prerelease",
"System.Text.RegularExpressions": "4.3.0-beta-24604-02",
"test-runtime": {
@@ -23,13 +25,29 @@
"Microsoft.DotNet.BuildTools.TestSuite": "1.0.0-prerelease-00830-02"
},
"frameworks": {
- "netstandard1.4": {}
- },
+ "netstandard1.6": {},
+ "netstandard1.7": {}
+ },
"supports": {
- "coreFx.Test.netcore50": {},
+ "coreFx.Test.net463": {},
"coreFx.Test.netcoreapp1.0": {},
- "coreFx.Test.net461": {},
- "coreFx.Test.net462": {},
- "coreFx.Test.net463": {}
+ "coreFx.Test.netcoreapp1.1-ns17": {
+ "netstandard1.7": [
+ "win7-x86",
+ "win7-x64",
+ "win10-arm64",
+ "osx.10.10-x64",
+ "centos.7-x64",
+ "debian.8-x64",
+ "rhel.7-x64",
+ "ubuntu.14.04-x64",
+ "ubuntu.16.04-x64",
+ "ubuntu.16.10-x64",
+ "fedora.23-x64",
+ "linux-x64",
+ "opensuse.13.2-x64",
+ "opensuse.42.1-x64"
+ ]
+ }
}
}