Skip to content

Commit

Permalink
Improve exception thrown when constructing SslCertificateTrust (#66763)
Browse files Browse the repository at this point in the history
* Improve exception thrown when constructing SslCertificateTrust

* Remove UnsupportedOSPlatform annotation

* fixup! Remove UnsupportedOSPlatform annotation

* Update ApiCompatBaseline
  • Loading branch information
rzikm committed Mar 30, 2022
1 parent b2e494c commit e9826ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ public sealed partial class SslCertificateTrust
public static SslCertificateTrust CreateForX509Store(
System.Security.Cryptography.X509Certificates.X509Store store,
bool sendTrustInHandshake = false) { throw null; }
[System.Runtime.Versioning.UnsupportedOSPlatform("windows")]
public static SslCertificateTrust CreateForX509Collection(
System.Security.Cryptography.X509Certificates.X509Certificate2Collection trustList,
bool sendTrustInHandshake = false) { throw null; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@ public static SslCertificateTrust CreateForX509Store(X509Store store, bool sendT
{
throw new PlatformNotSupportedException(SR.net_ssl_trust_store);
}
#else
#endif
if (sendTrustInHandshake && !System.OperatingSystem.IsLinux() && !System.OperatingSystem.IsMacOS() &&
// Necessary functions are available only on win 8 onwards
!OperatingSystem.IsWindowsVersionAtLeast(6, 2))
{
// to be removed when implemented.
throw new PlatformNotSupportedException(SR.net_ssl_trust_handshake);
}
#endif
if (!store.IsOpen)
{
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
Expand All @@ -40,13 +39,20 @@ public static SslCertificateTrust CreateForX509Store(X509Store store, bool sendT
return trust;
}

[UnsupportedOSPlatform("windows")]
public static SslCertificateTrust CreateForX509Collection(X509Certificate2Collection trustList, bool sendTrustInHandshake = false)
{

#if TARGET_WINDOWS
if (sendTrustInHandshake)
{
throw new PlatformNotSupportedException(SR.net_ssl_trust_collection);
}
#else
if (sendTrustInHandshake && !System.OperatingSystem.IsLinux() && !System.OperatingSystem.IsMacOS())
{
throw new PlatformNotSupportedException(SR.net_ssl_trust_handshake);
}
#endif

var trust = new SslCertificateTrust();
trust._trustList = trustList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatfo
Compat issues with assembly System.Diagnostics.Process:
CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MaxWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("freebsd")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation.
CannotChangeAttribute : Attribute 'System.Runtime.Versioning.SupportedOSPlatformAttribute' on 'System.Diagnostics.Process.MinWorkingSet.set(System.IntPtr)' changed from '[SupportedOSPlatformAttribute("freebsd")]' in the contract to '[SupportedOSPlatformAttribute("freebsd")]' in the implementation.
Compat issues with assembly System.Net.Security:
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Net.Security.SslCertificateTrust.CreateForX509Collection(System.Security.Cryptography.X509Certificates.X509Certificate2Collection, System.Boolean)' in the contract but not the implementation.
Compat issues with assembly System.Numerics.Vectors:
CannotRemoveAttribute : Attribute 'System.Runtime.CompilerServices.IsReadOnlyAttribute' exists on 'System.Numerics.Vector<T>.CopyTo(System.Span<System.Byte>)' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'System.Runtime.CompilerServices.IsReadOnlyAttribute' exists on 'System.Numerics.Vector<T>.CopyTo(System.Span<T>)' in the contract but not the implementation.
Expand Down Expand Up @@ -142,4 +144,4 @@ CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatfo
CannotRemoveAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' exists on 'System.Security.Cryptography.TripleDES' in the contract but not the implementation.
Compat issues with assembly System.Security.Cryptography.X509Certificates:
CannotChangeAttribute : Attribute 'System.Runtime.Versioning.UnsupportedOSPlatformAttribute' on 'System.Security.Cryptography.X509Certificates.PublicKey.GetDSAPublicKey()' changed from '[UnsupportedOSPlatformAttribute("ios")]' in the contract to '[UnsupportedOSPlatformAttribute("browser")]' in the implementation.
Total Issues: 135
Total Issues: 136

0 comments on commit e9826ba

Please sign in to comment.