@@ -2327,7 +2327,7 @@ private void GenerateADCSEnrollmentServerTests(ADWebService adws, string dnsHost
2327
2327
byte [ ] certificate ;
2328
2328
var protocols = new List < string > ( ) ;
2329
2329
Trace . WriteLine ( "[" + DateTime . Now + "] Test for " + dnsHostName + " 1 starts" ) ;
2330
- GenerateTLSInfo ( uri . Host , uri . Port , protocols , out certificate ) ;
2330
+ GenerateTLSInfo ( uri . Host , uri . Port , protocols , out certificate , "[" + DateTime . Now + "] " ) ;
2331
2331
Trace . WriteLine ( "[" + DateTime . Now + "] Test for " + dnsHostName + " 2 done for TLS" ) ;
2332
2332
2333
2333
enrollmentServer . SSLProtocol = protocols ;
@@ -2340,7 +2340,7 @@ private void GenerateADCSEnrollmentServerTests(ADWebService adws, string dnsHost
2340
2340
// web enrollment
2341
2341
// https access
2342
2342
// channel binding
2343
- var result = ConnectionTester . TestExtendedAuthentication ( uri , adws . Credential ) ;
2343
+ var result = ConnectionTester . TestExtendedAuthentication ( uri , adws . Credential , "[" + DateTime . Now + "] Test for " + dnsHostName + " " ) ;
2344
2344
Trace . WriteLine ( "[" + DateTime . Now + "] Test for " + dnsHostName + " 3 done for TestExtendedAuthentication" ) ;
2345
2345
if ( result == ConnectionTesterStatus . ChannelBindingDisabled )
2346
2346
{
@@ -2353,7 +2353,7 @@ private void GenerateADCSEnrollmentServerTests(ADWebService adws, string dnsHost
2353
2353
}
2354
2354
// http access
2355
2355
uri = new Uri ( "http://" + dnsHostName + "/certsrv/certrqxt.asp" ) ;
2356
- result = ConnectionTester . TestConnection ( uri , adws . Credential ) ;
2356
+ result = ConnectionTester . TestConnection ( uri , adws . Credential , "[" + DateTime . Now + "] Test for " + dnsHostName + " " ) ;
2357
2357
Trace . WriteLine ( "[" + DateTime . Now + "] Test for " + dnsHostName + " 4 done for TestConnection" ) ;
2358
2358
if ( result == ConnectionTesterStatus . AuthenticationSuccessfull )
2359
2359
{
@@ -2365,7 +2365,7 @@ private void GenerateADCSEnrollmentServerTests(ADWebService adws, string dnsHost
2365
2365
// channel binding
2366
2366
uri = new Uri ( "https://" + dnsHostName + "/" + System . Net . WebUtility . UrlEncode ( CAName ) + "_CES_Kerberos/service.svc" ) ;
2367
2367
2368
- result = ConnectionTester . TestExtendedAuthentication ( uri , adws . Credential ) ;
2368
+ result = ConnectionTester . TestExtendedAuthentication ( uri , adws . Credential , "[" + DateTime . Now + "] Test for " + dnsHostName + " " ) ;
2369
2369
Trace . WriteLine ( "[" + DateTime . Now + "] Test for " + dnsHostName + " 5 done for TestExtendedAuthentication" ) ;
2370
2370
if ( result == ConnectionTesterStatus . ChannelBindingDisabled )
2371
2371
{
@@ -2379,7 +2379,7 @@ private void GenerateADCSEnrollmentServerTests(ADWebService adws, string dnsHost
2379
2379
2380
2380
// http access
2381
2381
uri = new Uri ( "http://" + dnsHostName + "/" + System . Net . WebUtility . UrlEncode ( CAName ) + "_CES_Kerberos/service.svc" ) ;
2382
- result = ConnectionTester . TestConnection ( uri , adws . Credential ) ;
2382
+ result = ConnectionTester . TestConnection ( uri , adws . Credential , "[" + DateTime . Now + "] Test for " + dnsHostName + " " ) ;
2383
2383
Trace . WriteLine ( "[" + DateTime . Now + "] Test for " + dnsHostName + " 6 done for TestConnection" ) ;
2384
2384
if ( result == ConnectionTesterStatus . AuthenticationSuccessfull )
2385
2385
{
@@ -3129,7 +3129,7 @@ private void GenerateWSUSData(ADDomainInfo domainInfo, ADWebService adws)
3129
3129
{
3130
3130
byte [ ] certificate ;
3131
3131
var protocols = new List < string > ( ) ;
3132
- GenerateTLSInfo ( uri . Host , uri . Port , protocols , out certificate ) ;
3132
+ GenerateTLSInfo ( uri . Host , uri . Port , protocols , out certificate , "[" + DateTime . Now + "] " ) ;
3133
3133
cache [ key ] = new KeyValuePair < List < string > , byte [ ] > ( protocols , certificate ) ;
3134
3134
}
3135
3135
gpo . WSUSserverSSLProtocol = cache [ key ] . Key ;
@@ -3149,7 +3149,7 @@ private void GenerateWSUSData(ADDomainInfo domainInfo, ADWebService adws)
3149
3149
{
3150
3150
byte [ ] certificate ;
3151
3151
var protocols = new List < string > ( ) ;
3152
- GenerateTLSInfo ( uri . Host , uri . Port , protocols , out certificate ) ;
3152
+ GenerateTLSInfo ( uri . Host , uri . Port , protocols , out certificate , "[" + DateTime . Now + "] " ) ;
3153
3153
cache [ key ] = new KeyValuePair < List < string > , byte [ ] > ( protocols , certificate ) ;
3154
3154
}
3155
3155
gpo . WSUSserverAlternateSSLProtocol = cache [ key ] . Key ;
@@ -4962,12 +4962,12 @@ private void GenerateDomainControllerData(ADDomainInfo domainInfo, ADWebService
4962
4962
}
4963
4963
Trace . WriteLine ( "[" + threadId + "] Working on smb support " + dns ) ;
4964
4964
SMBSecurityModeEnum securityMode ;
4965
- if ( SmbScanner . SupportSMB1 ( dns , out securityMode ) )
4965
+ if ( SmbScanner . SupportSMB1 ( dns , out securityMode , "[" + threadId + "] " ) )
4966
4966
{
4967
4967
DC . SupportSMB1 = true ;
4968
4968
}
4969
4969
DC . SMB1SecurityMode = securityMode ;
4970
- if ( SmbScanner . SupportSMB2And3 ( dns , out securityMode ) )
4970
+ if ( SmbScanner . SupportSMB2And3 ( dns , out securityMode , "[" + threadId + "] " ) )
4971
4971
{
4972
4972
DC . SupportSMB2OrSMB3 = true ;
4973
4973
}
@@ -4979,15 +4979,15 @@ private void GenerateDomainControllerData(ADDomainInfo domainInfo, ADWebService
4979
4979
}
4980
4980
if ( DC . SMB1SecurityMode != SMBSecurityModeEnum . NotTested && DC . SMB2SecurityMode != SMBSecurityModeEnum . NotTested )
4981
4981
{
4982
- if ( NamedPipeTester . IsRemotePipeAccessible ( dns , NamedPipeTester . WebClientPipeName ) )
4982
+ if ( NamedPipeTester . IsRemotePipeAccessible ( dns , NamedPipeTester . WebClientPipeName , "[" + threadId + "] " ) )
4983
4983
{
4984
4984
DC . WebClientEnabled = true ;
4985
4985
}
4986
4986
}
4987
4987
Trace . WriteLine ( "[" + threadId + "] Working on ldap ssl " + dns ) ;
4988
- GenerateTLSConnectionInfo ( dns , DC , adws . Credential ) ;
4988
+ GenerateTLSConnectionInfo ( dns , DC , adws . Credential , threadId ) ;
4989
4989
Trace . WriteLine ( "[" + threadId + "] Working on ldap signing requirements " + dns ) ;
4990
- GenerateLDAPSigningRequirementInfo ( dns , DC , adws . Credential ) ;
4990
+ GenerateLDAPSigningRequirementInfo ( dns , DC , adws . Credential , threadId ) ;
4991
4991
Trace . WriteLine ( "[" + threadId + "] Done for " + dns ) ;
4992
4992
}
4993
4993
} ;
@@ -5042,36 +5042,40 @@ private void GenerateDomainControllerData(ADDomainInfo domainInfo, ADWebService
5042
5042
}
5043
5043
}
5044
5044
5045
- private void GenerateTLSConnectionInfo ( string dns , HealthcheckDomainController DC , NetworkCredential credentials )
5045
+ private void GenerateTLSConnectionInfo ( string dns , HealthcheckDomainController DC , NetworkCredential credentials , int threadId )
5046
5046
{
5047
5047
DC . LDAPSProtocols = new List < string > ( ) ;
5048
5048
byte [ ] certificate ;
5049
- GenerateTLSInfo ( dns , 636 , DC . LDAPSProtocols , out certificate ) ;
5049
+ Trace . WriteLine ( "[" + threadId + "] GenerateTLSInfo" ) ;
5050
+ GenerateTLSInfo ( dns , 636 , DC . LDAPSProtocols , out certificate , "[" + threadId + "] " ) ;
5050
5051
DC . LDAPCertificate = certificate ;
5051
5052
if ( DC . LDAPSProtocols . Count > 0 )
5052
5053
{
5053
5054
if ( DoesComputerMatchDns ( dns ) )
5054
5055
{
5055
- Trace . WriteLine ( "Test ignored because tested on the DC itself" ) ;
5056
+ Trace . WriteLine ( "[" + threadId + "] Test ignored because tested on the DC itself") ;
5056
5057
return ;
5057
5058
}
5058
-
5059
- var result = ConnectionTester . TestExtendedAuthentication ( new Uri ( "ldaps://" + dns ) , credentials ) ;
5059
+ Trace . WriteLine ( "[" + threadId + "] TestExtendedAuthentication" ) ;
5060
+ var result = ConnectionTester . TestExtendedAuthentication ( new Uri ( "ldaps://" + dns ) , credentials , "[" + threadId + "] " ) ;
5061
+ Trace . WriteLine ( "[" + threadId + "] Result:" + result ) ;
5060
5062
if ( result == ConnectionTesterStatus . ChannelBindingDisabled )
5061
5063
{
5062
5064
DC . ChannelBindingDisabled = true ;
5063
5065
}
5064
5066
}
5065
5067
}
5066
5068
5067
- private void GenerateLDAPSigningRequirementInfo ( string dns , HealthcheckDomainController DC , NetworkCredential credentials )
5069
+ private void GenerateLDAPSigningRequirementInfo ( string dns , HealthcheckDomainController DC , NetworkCredential credentials , int threadId )
5068
5070
{
5069
5071
if ( DoesComputerMatchDns ( dns ) )
5070
5072
{
5071
- Trace . WriteLine ( "Test ignored because tested on the DC itself" ) ;
5073
+ Trace . WriteLine ( "[" + threadId + "] Test ignored because tested on the DC itself") ;
5072
5074
return ;
5073
5075
}
5074
- var result = ConnectionTester . TestSignatureRequiredEnabled ( new Uri ( "ldap://" + dns ) , credentials ) ;
5076
+ Trace . WriteLine ( "[" + threadId + "] TestSignatureRequiredEnabled" ) ;
5077
+ var result = ConnectionTester . TestSignatureRequiredEnabled ( new Uri ( "ldap://" + dns ) , credentials , "[" + threadId + "] " ) ;
5078
+ Trace . WriteLine ( "[" + threadId + "] Result:" + result ) ;
5075
5079
if ( result == ConnectionTesterStatus . SignatureNotRequired )
5076
5080
{
5077
5081
DC . LdapServerSigningRequirementDisabled = true ;
@@ -5084,72 +5088,44 @@ bool DoesComputerMatchDns(string Dns)
5084
5088
return string . Equals ( hostName , Dns , StringComparison . OrdinalIgnoreCase ) ;
5085
5089
}
5086
5090
5087
- private void GenerateTLSInfo ( string dns , int port , List < string > protocols , out byte [ ] certificate )
5091
+ private void GenerateTLSInfo ( string dns , int port , List < string > protocols , out byte [ ] certificate , string logPrefix )
5088
5092
{
5089
5093
certificate = null ;
5090
5094
foreach ( SslProtocols protocol in Enum . GetValues ( typeof ( SslProtocols ) ) )
5091
5095
{
5092
- if ( protocol == SslProtocols . None )
5093
- continue ;
5094
5096
if ( protocol == SslProtocols . Default )
5095
- {
5096
- try
5097
- {
5098
- byte [ ] c = null ;
5099
- using ( TcpClient client = new TcpClient ( dns , port ) )
5100
- {
5101
- client . ReceiveTimeout = 1000 ;
5102
- client . SendTimeout = 1000 ;
5103
- using ( SslStream sslstream = new SslStream ( client . GetStream ( ) , false ,
5104
- ( object sender , X509Certificate CACert , X509Chain CAChain , SslPolicyErrors sslPolicyErrors )
5105
- =>
5106
- { c = CACert . GetRawCertData ( ) ; return true ; }
5107
- , null ) )
5108
- {
5109
- Trace . WriteLine ( "normal auth for " + dns ) ;
5110
- sslstream . AuthenticateAsClient ( dns , null , protocol , false ) ;
5111
- Trace . WriteLine ( "normal auth supported for " + dns ) ;
5112
- certificate = c ;
5113
- }
5114
- }
5115
- }
5116
- catch ( SocketException )
5117
- {
5118
- Trace . WriteLine ( "SSL not supported for " + dns ) ;
5119
- return ;
5120
- }
5121
- catch ( Exception )
5122
- {
5123
- }
5124
5097
continue ;
5125
- }
5098
+ if ( protocol == SslProtocols . None )
5099
+ continue ;
5126
5100
try
5127
5101
{
5102
+ byte [ ] c = null ;
5128
5103
using ( TcpClient client = new TcpClient ( dns , port ) )
5129
5104
{
5130
5105
client . ReceiveTimeout = 1000 ;
5131
5106
client . SendTimeout = 1000 ;
5132
5107
using ( SslStream sslstream = new SslStream ( client . GetStream ( ) , false ,
5133
5108
( object sender , X509Certificate CACert , X509Chain CAChain , SslPolicyErrors sslPolicyErrors )
5134
5109
=>
5135
- { return true ; }
5110
+ { c = CACert . GetRawCertData ( ) ; return true ; }
5136
5111
, null ) )
5137
5112
{
5138
- Trace . WriteLine ( protocol + " before auth for " + dns ) ;
5113
+ Trace . WriteLine ( logPrefix + protocol + " before auth for " + dns ) ;
5139
5114
sslstream . AuthenticateAsClient ( dns , null , protocol , false ) ;
5140
- Trace . WriteLine ( protocol + " supported for " + dns ) ;
5115
+ Trace . WriteLine ( logPrefix + protocol + " supported for " + dns ) ;
5116
+ certificate = c ;
5141
5117
protocols . Add ( protocol . ToString ( ) ) ;
5142
5118
}
5143
5119
}
5144
5120
}
5145
5121
catch ( SocketException )
5146
5122
{
5147
- Trace . WriteLine ( "SSL not supported for " + dns ) ;
5123
+ Trace . WriteLine ( logPrefix + "SSL not supported for " + dns ) ;
5148
5124
return ;
5149
5125
}
5150
5126
catch ( Exception ex )
5151
5127
{
5152
- Trace . WriteLine ( protocol + " not supported for " + dns + ":" + port + " (" + ex . Message + ( ex . InnerException == null ? null : " - " + ex . InnerException . Message ) + ")" ) ;
5128
+ Trace . WriteLine ( logPrefix + protocol + " not supported for " + dns + ":" + port + " (" + ex . Message + ( ex . InnerException == null ? null : " - " + ex . InnerException . Message ) + ")" ) ;
5153
5129
}
5154
5130
}
5155
5131
}
0 commit comments