@@ -10,14 +10,16 @@ namespace System.ServiceModel
1010{
1111 public sealed class UnixDomainSocketSecurity
1212 {
13- internal const UnixDomainSocketSecurityMode DefaultMode = UnixDomainSocketSecurityMode . Transport ;
13+ private static UnixDomainSocketSecurityMode s_defaultMode =
14+ RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ?
15+ UnixDomainSocketSecurityMode . Transport : UnixDomainSocketSecurityMode . TransportCredentialOnly ;
16+
1417
1518 private UnixDomainSocketSecurityMode _mode ;
1619
1720 public UnixDomainSocketSecurity ( )
1821 {
19- _mode = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ?
20- UnixDomainSocketSecurityMode . Transport : UnixDomainSocketSecurityMode . TransportCredentialOnly ;
22+ _mode = s_defaultMode ;
2123 Transport = new UnixDomainSocketTransportSecurity ( ) ;
2224 }
2325
@@ -27,14 +29,14 @@ private UnixDomainSocketSecurity(UnixDomainSocketSecurityMode mode, UnixDomainSo
2729 string . Format ( "Invalid SecurityMode value: {0} = {1} (default is {2} = {3})." ,
2830 ( int ) mode ,
2931 mode . ToString ( ) ,
30- ( int ) SecurityMode . Transport ,
31- SecurityMode . Transport . ToString ( ) ) ) ;
32+ ( int ) s_defaultMode ,
33+ s_defaultMode . ToString ( ) ) ) ;
3234
3335 _mode = mode ;
3436 Transport = transportSecurity ?? new UnixDomainSocketTransportSecurity ( ) ;
3537 }
3638
37- [ DefaultValue ( DefaultMode ) ]
39+
3840 public UnixDomainSocketSecurityMode Mode
3941 {
4042 get { return _mode ; }
@@ -54,7 +56,9 @@ internal BindingElement CreateTransportSecurity()
5456 {
5557 if ( _mode == UnixDomainSocketSecurityMode . Transport || _mode == UnixDomainSocketSecurityMode . TransportCredentialOnly )
5658 {
57- if ( _mode == UnixDomainSocketSecurityMode . TransportCredentialOnly && Transport . ClientCredentialType != UnixDomainSocketClientCredentialType . PosixIdentity )
59+ if ( ( _mode == UnixDomainSocketSecurityMode . TransportCredentialOnly && Transport . ClientCredentialType != UnixDomainSocketClientCredentialType . PosixIdentity )
60+ ||
61+ ( _mode == UnixDomainSocketSecurityMode . Transport && Transport . ClientCredentialType == UnixDomainSocketClientCredentialType . PosixIdentity ) )
5862 {
5963 throw DiagnosticUtility . ExceptionUtility . ThrowHelperError ( new NotSupportedException ( SR . Format ( SR . UnsupportedSecuritySetting , "Mode" , _mode ) ) ) ;
6064 }
0 commit comments