System.Net.ServicePointManager.ChainValidationHelper.CheckServerIdentity C# (CSharp) Method

CheckServerIdentity() static private method

static private CheckServerIdentity ( Mono cert, string targetHost ) : bool
cert Mono
targetHost string
return bool
			static bool CheckServerIdentity (Mono.Security.X509.X509Certificate cert, string targetHost) 
			{
				try {
					Mono.Security.X509.X509Extension ext = cert.Extensions ["2.5.29.17"];
					// 1. subjectAltName
					if (ext != null) {
						SubjectAltNameExtension subjectAltName = new SubjectAltNameExtension (ext);
						// 1.1 - multiple dNSName
						foreach (string dns in subjectAltName.DNSNames) {
							// 1.2 TODO - wildcard support
							if (Match (targetHost, dns))
								return true;
						}
						// 2. ipAddress
						foreach (string ip in subjectAltName.IPAddresses) {
							// 2.1. Exact match required
							if (ip == targetHost)
								return true;
						}
					}
					// 3. Common Name (CN=)
					return CheckDomainName (cert.SubjectName, targetHost);
				} catch (Exception e) {
					Console.Error.WriteLine ("ERROR processing certificate: {0}", e);
					Console.Error.WriteLine ("Please, report this problem to the Mono team");
					return false;
				}
			}