From: Jeremy Barton Date: Fri, 21 Feb 2020 01:52:44 +0000 (-0800) Subject: Make X509Certificate.Export non-null-returning X-Git-Tag: submit/tizen/20210909.063632~9579 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c1fca6912ab173b0d607d1d2f6139a3dbca79fc;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Make X509Certificate.Export non-null-returning --- diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.cs b/src/libraries/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.cs index 8cbe362..78fe34a 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/ref/System.Security.Cryptography.X509Certificates.cs @@ -158,10 +158,10 @@ namespace System.Security.Cryptography.X509Certificates protected virtual void Dispose(bool disposing) { } public override bool Equals(object? obj) { throw null; } public virtual bool Equals(System.Security.Cryptography.X509Certificates.X509Certificate? other) { throw null; } - public virtual byte[]? Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType) { throw null; } + public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType) { throw null; } [System.CLSCompliantAttribute(false)] - public virtual byte[]? Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, System.Security.SecureString? password) { throw null; } - public virtual byte[]? Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, string? password) { throw null; } + public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, System.Security.SecureString? password) { throw null; } + public virtual byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType, string? password) { throw null; } protected static string FormatDate(System.DateTime date) { throw null; } public virtual byte[] GetCertHash() { throw null; } public virtual byte[] GetCertHash(System.Security.Cryptography.HashAlgorithmName hashAlgorithm) { throw null; } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/ICertificatePalCore.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/ICertificatePalCore.cs index 1925598..e6f5381 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/ICertificatePalCore.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/ICertificatePalCore.cs @@ -29,6 +29,6 @@ namespace Internal.Cryptography DateTime NotAfter { get; } DateTime NotBefore { get; } byte[] RawData { get; } - byte[]? Export(X509ContentType contentType, SafePasswordHandle password); + byte[] Export(X509ContentType contentType, SafePasswordHandle password); } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/AppleCertificatePal.Pkcs12.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/AppleCertificatePal.Pkcs12.cs index 03ae114..cce34ee 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/AppleCertificatePal.Pkcs12.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/AppleCertificatePal.Pkcs12.cs @@ -141,7 +141,7 @@ namespace Internal.Cryptography.Pal public DateTime NotAfter => _realPal.NotAfter; public DateTime NotBefore => _realPal.NotBefore; public byte[] RawData => _realPal.RawData; - public byte[]? Export(X509ContentType contentType, SafePasswordHandle password) => + public byte[] Export(X509ContentType contentType, SafePasswordHandle password) => _realPal.Export(contentType, password); } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/AppleCertificatePal.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/AppleCertificatePal.cs index 51f56c1..08faefd 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/AppleCertificatePal.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.OSX/AppleCertificatePal.cs @@ -623,11 +623,13 @@ namespace Internal.Cryptography.Pal sb.AppendLine("[Private Key]"); } - public byte[]? Export(X509ContentType contentType, SafePasswordHandle password) + public byte[] Export(X509ContentType contentType, SafePasswordHandle password) { using (IExportPal storePal = StorePal.FromCertificate(this)) { - return storePal.Export(contentType, password); + byte[]? exported = storePal.Export(contentType, password); + Debug.Assert(exported != null); + return exported; } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs index 1c1e68c..a3e6479 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Unix/OpenSslX509CertificateReader.cs @@ -769,11 +769,13 @@ namespace Internal.Cryptography.Pal throw new CryptographicException(); } - public byte[]? Export(X509ContentType contentType, SafePasswordHandle password) + public byte[] Export(X509ContentType contentType, SafePasswordHandle password) { using (IExportPal storePal = StorePal.FromCertificate(this)) { - return storePal.Export (contentType, password); + byte[]? exported = storePal.Export(contentType, password); + Debug.Assert(exported != null); + return exported; } } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs index 598fd63..aec31f0 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/Internal/Cryptography/Pal.Windows/CertificatePal.cs @@ -537,11 +537,13 @@ namespace Internal.Cryptography.Pal _certContext = certContext; } - public byte[]? Export(X509ContentType contentType, SafePasswordHandle password) + public byte[] Export(X509ContentType contentType, SafePasswordHandle password) { using (IExportPal storePal = StorePal.FromCertificate(this)) { - return storePal.Export(contentType, password); + byte[]? exported = storePal.Export(contentType, password); + Debug.Assert(exported != null); + return exported; } } } diff --git a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs index 47553cb..41c6e04 100644 --- a/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs +++ b/src/libraries/System.Security.Cryptography.X509Certificates/src/System/Security/Cryptography/X509Certificates/X509Certificate.cs @@ -271,12 +271,12 @@ namespace System.Security.Cryptography.X509Certificates return true; } - public virtual byte[]? Export(X509ContentType contentType) + public virtual byte[] Export(X509ContentType contentType) { return Export(contentType, (string?)null); } - public virtual byte[]? Export(X509ContentType contentType, string? password) + public virtual byte[] Export(X509ContentType contentType, string? password) { VerifyContentType(contentType); @@ -290,7 +290,7 @@ namespace System.Security.Cryptography.X509Certificates } [System.CLSCompliantAttribute(false)] - public virtual byte[]? Export(X509ContentType contentType, SecureString? password) + public virtual byte[] Export(X509ContentType contentType, SecureString? password) { VerifyContentType(contentType);