Skip to content

Commit 9ccd6bd

Browse files
committed
Disable PeerTrust certificate validation on OSX
1 parent 2856c49 commit 9ccd6bd

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/System.Private.ServiceModel/src/Resources/Strings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,4 +1968,7 @@
19681968
<data name="SFxChannelTerminated0" xml:space="preserve">
19691969
<value>An operation marked as IsTerminating has already been invoked on this channel, causing the channel's connection to terminate. No more operations may be invoked on this channel. Please re-create the channel to continue communication.</value>
19701970
</data>
1971+
<data name="PeerTrustNotSupportedOnOSX" xml:space="preserve">
1972+
<value>Peer Trust certificate validation is not supported on OSX. See https://go.microsoft.com/fwlink/?linkid=849976 for details.</value>
1973+
</data>
19711974
</root>

src/System.Private.ServiceModel/src/System/ServiceModel/Security/X509ServiceCertificateAuthentication.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using System.IdentityModel.Selectors;
77
using System.Runtime;
8+
using System.Runtime.InteropServices;
89
using System.Security.Cryptography.X509Certificates;
910

1011
namespace System.ServiceModel.Security
@@ -59,6 +60,13 @@ public X509CertificateValidationMode CertificateValidationMode
5960
set
6061
{
6162
X509CertificateValidationModeHelper.Validate(value);
63+
64+
if ((value == X509CertificateValidationMode.PeerTrust || value == X509CertificateValidationMode.PeerOrChainTrust) &&
65+
RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
66+
{
67+
throw ExceptionHelper.PlatformNotSupported(SR.PeerTrustNotSupportedOnOSX);
68+
}
69+
6270
ThrowIfImmutable();
6371
_certificateValidationMode = value;
6472
}

0 commit comments

Comments
 (0)