using System;
using System.Collections;
using System.Collections.Specialized;
using System.Globalization;
using System.IO;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Mono.Security.Protocol.Tls;
using Mono.Security.X509;
using Mono.Security.X509.Extensions;
namespace System.Net
{
/// Manages the collection of objects.
// Token: 0x02000254 RID: 596
public class ServicePointManager
{
// Token: 0x06001544 RID: 5444 RVA: 0x00043E94 File Offset: 0x00042094
private ServicePointManager()
{
}
/// Gets or sets policy for server certificates.
/// An object that implements the interface.
///
///
///
// Token: 0x170006F6 RID: 1782
// (get) Token: 0x06001546 RID: 5446 RVA: 0x00043EEC File Offset: 0x000420EC
// (set) Token: 0x06001547 RID: 5447 RVA: 0x00043EF4 File Offset: 0x000420F4
[Obsolete("Use ServerCertificateValidationCallback instead", false)]
public static ICertificatePolicy CertificatePolicy
{
get
{
return ServicePointManager.policy;
}
set
{
ServicePointManager.policy = value;
}
}
/// Gets or sets a value that indicates whether the certificate is checked against the certificate authority revocation list.
/// true if the certificate revocation list is checked; otherwise, false.
///
///
///
///
// Token: 0x170006F7 RID: 1783
// (get) Token: 0x06001548 RID: 5448 RVA: 0x00043EFC File Offset: 0x000420FC
// (set) Token: 0x06001549 RID: 5449 RVA: 0x00043F04 File Offset: 0x00042104
[global::System.MonoTODO("CRL checks not implemented")]
public static bool CheckCertificateRevocationList
{
get
{
return ServicePointManager._checkCRL;
}
set
{
ServicePointManager._checkCRL = false;
}
}
/// Gets or sets the maximum number of concurrent connections allowed by a object.
/// The maximum number of concurrent connections allowed by a object. The default value is 2.
///
/// is less than or equal to 0.
///
///
///
///
///
// Token: 0x170006F8 RID: 1784
// (get) Token: 0x0600154A RID: 5450 RVA: 0x00043F0C File Offset: 0x0004210C
// (set) Token: 0x0600154B RID: 5451 RVA: 0x00043F14 File Offset: 0x00042114
public static int DefaultConnectionLimit
{
get
{
return ServicePointManager.defaultConnectionLimit;
}
set
{
if (value <= 0)
{
throw new ArgumentOutOfRangeException("value");
}
ServicePointManager.defaultConnectionLimit = value;
}
}
// Token: 0x0600154C RID: 5452 RVA: 0x00043F30 File Offset: 0x00042130
private static Exception GetMustImplement()
{
return new NotImplementedException();
}
/// Gets or sets a value that indicates how long a Domain Name Service (DNS) resolution is considered valid.
/// The time-out value, in milliseconds. A value of -1 indicates an infinite time-out period. The default value is 120,000 milliseconds (two minutes).
// Token: 0x170006F9 RID: 1785
// (get) Token: 0x0600154D RID: 5453 RVA: 0x00043F38 File Offset: 0x00042138
// (set) Token: 0x0600154E RID: 5454 RVA: 0x00043F40 File Offset: 0x00042140
[global::System.MonoTODO]
public static int DnsRefreshTimeout
{
get
{
throw ServicePointManager.GetMustImplement();
}
set
{
throw ServicePointManager.GetMustImplement();
}
}
/// Gets or sets a value that indicates whether a Domain Name Service (DNS) resolution rotates among the applicable Internet Protocol (IP) addresses.
/// false if a DNS resolution always returns the first IP address for a particular host; otherwise true. The default is false.
// Token: 0x170006FA RID: 1786
// (get) Token: 0x0600154F RID: 5455 RVA: 0x00043F48 File Offset: 0x00042148
// (set) Token: 0x06001550 RID: 5456 RVA: 0x00043F50 File Offset: 0x00042150
[global::System.MonoTODO]
public static bool EnableDnsRoundRobin
{
get
{
throw ServicePointManager.GetMustImplement();
}
set
{
throw ServicePointManager.GetMustImplement();
}
}
/// Gets or sets the maximum idle time of a object.
/// The maximum idle time, in milliseconds, of a object. The default value is 100,000 milliseconds (100 seconds).
///
/// is less than or greater than .
///
///
///
// Token: 0x170006FB RID: 1787
// (get) Token: 0x06001551 RID: 5457 RVA: 0x00043F58 File Offset: 0x00042158
// (set) Token: 0x06001552 RID: 5458 RVA: 0x00043F60 File Offset: 0x00042160
public static int MaxServicePointIdleTime
{
get
{
return ServicePointManager.maxServicePointIdleTime;
}
set
{
if (value < -2 || value > 2147483647)
{
throw new ArgumentOutOfRangeException("value");
}
ServicePointManager.maxServicePointIdleTime = value;
}
}
/// Gets or sets the maximum number of objects to maintain at any time.
/// The maximum number of objects to maintain. The default value is 0, which means there is no limit to the number of objects.
///
/// is less than 0 or greater than .
///
///
///
// Token: 0x170006FC RID: 1788
// (get) Token: 0x06001553 RID: 5459 RVA: 0x00043F94 File Offset: 0x00042194
// (set) Token: 0x06001554 RID: 5460 RVA: 0x00043F9C File Offset: 0x0004219C
public static int MaxServicePoints
{
get
{
return ServicePointManager.maxServicePoints;
}
set
{
if (value < 0)
{
throw new ArgumentException("value");
}
ServicePointManager.maxServicePoints = value;
ServicePointManager.RecycleServicePoints();
}
}
/// Gets or sets the security protocol used by the objects managed by the object.
/// One of the values defined in the enumeration.
/// The value specified to set the property is not a valid enumeration value.
// Token: 0x170006FD RID: 1789
// (get) Token: 0x06001555 RID: 5461 RVA: 0x00043FBC File Offset: 0x000421BC
// (set) Token: 0x06001556 RID: 5462 RVA: 0x00043FC4 File Offset: 0x000421C4
public static SecurityProtocolType SecurityProtocol
{
get
{
return ServicePointManager._securityProtocol;
}
set
{
ServicePointManager._securityProtocol = value;
}
}
/// Gets or sets the callback to validate a server certificate.
/// A The default value is null.
// Token: 0x170006FE RID: 1790
// (get) Token: 0x06001557 RID: 5463 RVA: 0x00043FCC File Offset: 0x000421CC
// (set) Token: 0x06001558 RID: 5464 RVA: 0x00043FD4 File Offset: 0x000421D4
public static global::System.Net.Security.RemoteCertificateValidationCallback ServerCertificateValidationCallback
{
get
{
return ServicePointManager.server_cert_cb;
}
set
{
ServicePointManager.server_cert_cb = value;
}
}
/// Gets or sets a value that determines whether 100-Continue behavior is used.
/// true to enable 100-Continue behavior. The default value is true.
///
///
///
///
// Token: 0x170006FF RID: 1791
// (get) Token: 0x06001559 RID: 5465 RVA: 0x00043FDC File Offset: 0x000421DC
// (set) Token: 0x0600155A RID: 5466 RVA: 0x00043FE4 File Offset: 0x000421E4
public static bool Expect100Continue
{
get
{
return ServicePointManager.expectContinue;
}
set
{
ServicePointManager.expectContinue = value;
}
}
/// Determines whether the Nagle algorithm is used by the service points managed by this object.
/// true to use the Nagle algorithm; otherwise, false. The default value is true.
///
///
///
///
// Token: 0x17000700 RID: 1792
// (get) Token: 0x0600155B RID: 5467 RVA: 0x00043FEC File Offset: 0x000421EC
// (set) Token: 0x0600155C RID: 5468 RVA: 0x00043FF4 File Offset: 0x000421F4
public static bool UseNagleAlgorithm
{
get
{
return ServicePointManager.useNagle;
}
set
{
ServicePointManager.useNagle = value;
}
}
/// Finds an existing object or creates a new object to manage communications with the specified object.
/// The object that manages communications for the request.
/// The object of the Internet resource to contact.
///
/// is null.
/// The maximum number of objects defined in has been reached.
///
///
///
///
// Token: 0x0600155D RID: 5469 RVA: 0x00043FFC File Offset: 0x000421FC
public static ServicePoint FindServicePoint(global::System.Uri address)
{
return ServicePointManager.FindServicePoint(address, GlobalProxySelection.Select);
}
/// Finds an existing object or creates a new object to manage communications with the specified Uniform Resource Identifier (URI).
/// The object that manages communications for the request.
/// The URI of the Internet resource to be contacted.
/// The proxy data for this request.
/// The URI specified in is invalid.
/// The maximum number of objects defined in has been reached.
///
///
///
///
// Token: 0x0600155E RID: 5470 RVA: 0x0004400C File Offset: 0x0004220C
public static ServicePoint FindServicePoint(string uriString, IWebProxy proxy)
{
return ServicePointManager.FindServicePoint(new global::System.Uri(uriString), proxy);
}
/// Finds an existing object or creates a new object to manage communications with the specified object.
/// The object that manages communications for the request.
/// A object that contains the address of the Internet resource to contact.
/// The proxy data for this request.
///
/// is null.
/// The maximum number of objects defined in has been reached.
///
///
///
///
// Token: 0x0600155F RID: 5471 RVA: 0x0004401C File Offset: 0x0004221C
public static ServicePoint FindServicePoint(global::System.Uri address, IWebProxy proxy)
{
if (address == null)
{
throw new ArgumentNullException("address");
}
ServicePointManager.RecycleServicePoints();
bool flag = false;
bool flag2 = false;
if (proxy != null && !proxy.IsBypassed(address))
{
flag = true;
bool flag3 = address.Scheme == "https";
address = proxy.GetProxy(address);
if (address.Scheme != "http" && !flag3)
{
throw new NotSupportedException("Proxy scheme not supported.");
}
if (flag3 && address.Scheme == "http")
{
flag2 = true;
}
}
address = new global::System.Uri(address.Scheme + "://" + address.Authority);
ServicePoint servicePoint = null;
global::System.Collections.Specialized.HybridDictionary hybridDictionary = ServicePointManager.servicePoints;
lock (hybridDictionary)
{
ServicePointManager.SPKey spkey = new ServicePointManager.SPKey(address, flag2);
servicePoint = ServicePointManager.servicePoints[spkey] as ServicePoint;
if (servicePoint != null)
{
return servicePoint;
}
if (ServicePointManager.maxServicePoints > 0 && ServicePointManager.servicePoints.Count >= ServicePointManager.maxServicePoints)
{
throw new InvalidOperationException("maximum number of service points reached");
}
string text = address.ToString();
int num = ServicePointManager.defaultConnectionLimit;
servicePoint = new ServicePoint(address, num, ServicePointManager.maxServicePointIdleTime);
servicePoint.Expect100Continue = ServicePointManager.expectContinue;
servicePoint.UseNagleAlgorithm = ServicePointManager.useNagle;
servicePoint.UsesProxy = flag;
servicePoint.UseConnect = flag2;
ServicePointManager.servicePoints.Add(spkey, servicePoint);
}
return servicePoint;
}
// Token: 0x06001560 RID: 5472 RVA: 0x000441B8 File Offset: 0x000423B8
internal static void RecycleServicePoints()
{
ArrayList arrayList = new ArrayList();
global::System.Collections.Specialized.HybridDictionary hybridDictionary = ServicePointManager.servicePoints;
lock (hybridDictionary)
{
IDictionaryEnumerator dictionaryEnumerator = ServicePointManager.servicePoints.GetEnumerator();
while (dictionaryEnumerator.MoveNext())
{
ServicePoint servicePoint = (ServicePoint)dictionaryEnumerator.Value;
if (servicePoint.AvailableForRecycling)
{
arrayList.Add(dictionaryEnumerator.Key);
}
}
for (int i = 0; i < arrayList.Count; i++)
{
ServicePointManager.servicePoints.Remove(arrayList[i]);
}
if (ServicePointManager.maxServicePoints != 0 && ServicePointManager.servicePoints.Count > ServicePointManager.maxServicePoints)
{
SortedList sortedList = new SortedList(ServicePointManager.servicePoints.Count);
dictionaryEnumerator = ServicePointManager.servicePoints.GetEnumerator();
while (dictionaryEnumerator.MoveNext())
{
ServicePoint servicePoint2 = (ServicePoint)dictionaryEnumerator.Value;
if (servicePoint2.CurrentConnections == 0)
{
while (sortedList.ContainsKey(servicePoint2.IdleSince))
{
servicePoint2.IdleSince = servicePoint2.IdleSince.AddMilliseconds(1.0);
}
sortedList.Add(servicePoint2.IdleSince, servicePoint2.Address);
}
}
int num = 0;
while (num < sortedList.Count && ServicePointManager.servicePoints.Count > ServicePointManager.maxServicePoints)
{
ServicePointManager.servicePoints.Remove(sortedList.GetByIndex(num));
num++;
}
}
}
}
/// The default number of non-persistent connections (4) allowed on a object connected to an HTTP/1.0 or later server. This field is constant but is no longer used in the .NET Framework 2.0.
// Token: 0x040011BF RID: 4543
public const int DefaultNonPersistentConnectionLimit = 4;
/// The default number of persistent connections (2) allowed on a object connected to an HTTP/1.1 or later server. This field is constant and is used to initialize the property if the value of the property has not been set either directly or through configuration.
// Token: 0x040011C0 RID: 4544
public const int DefaultPersistentConnectionLimit = 2;
// Token: 0x040011C1 RID: 4545
private static global::System.Collections.Specialized.HybridDictionary servicePoints = new global::System.Collections.Specialized.HybridDictionary();
// Token: 0x040011C2 RID: 4546
private static ICertificatePolicy policy = new DefaultCertificatePolicy();
// Token: 0x040011C3 RID: 4547
private static int defaultConnectionLimit = 2;
// Token: 0x040011C4 RID: 4548
private static int maxServicePointIdleTime = 900000;
// Token: 0x040011C5 RID: 4549
private static int maxServicePoints = 0;
// Token: 0x040011C6 RID: 4550
private static bool _checkCRL = false;
// Token: 0x040011C7 RID: 4551
private static SecurityProtocolType _securityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
// Token: 0x040011C8 RID: 4552
private static bool expectContinue = true;
// Token: 0x040011C9 RID: 4553
private static bool useNagle;
// Token: 0x040011CA RID: 4554
private static global::System.Net.Security.RemoteCertificateValidationCallback server_cert_cb;
// Token: 0x02000255 RID: 597
private class SPKey
{
// Token: 0x06001561 RID: 5473 RVA: 0x00044370 File Offset: 0x00042570
public SPKey(global::System.Uri uri, bool use_connect)
{
this.uri = uri;
this.use_connect = use_connect;
}
// Token: 0x17000701 RID: 1793
// (get) Token: 0x06001562 RID: 5474 RVA: 0x00044388 File Offset: 0x00042588
public global::System.Uri Uri
{
get
{
return this.uri;
}
}
// Token: 0x17000702 RID: 1794
// (get) Token: 0x06001563 RID: 5475 RVA: 0x00044390 File Offset: 0x00042590
public bool UseConnect
{
get
{
return this.use_connect;
}
}
// Token: 0x06001564 RID: 5476 RVA: 0x00044398 File Offset: 0x00042598
public override int GetHashCode()
{
return this.uri.GetHashCode() + ((!this.use_connect) ? 0 : 1);
}
// Token: 0x06001565 RID: 5477 RVA: 0x000443B8 File Offset: 0x000425B8
public override bool Equals(object obj)
{
ServicePointManager.SPKey spkey = obj as ServicePointManager.SPKey;
return obj != null && this.uri.Equals(spkey.uri) && spkey.use_connect == this.use_connect;
}
// Token: 0x040011CB RID: 4555
private global::System.Uri uri;
// Token: 0x040011CC RID: 4556
private bool use_connect;
}
// Token: 0x02000256 RID: 598
internal class ChainValidationHelper
{
// Token: 0x06001566 RID: 5478 RVA: 0x000443FC File Offset: 0x000425FC
public ChainValidationHelper(object sender)
{
this.sender = sender;
}
// Token: 0x17000703 RID: 1795
// (get) Token: 0x06001568 RID: 5480 RVA: 0x00044428 File Offset: 0x00042628
// (set) Token: 0x06001569 RID: 5481 RVA: 0x00044474 File Offset: 0x00042674
public string Host
{
get
{
if (this.host == null && this.sender is HttpWebRequest)
{
this.host = ((HttpWebRequest)this.sender).Address.Host;
}
return this.host;
}
set
{
this.host = value;
}
}
// Token: 0x0600156A RID: 5482 RVA: 0x00044480 File Offset: 0x00042680
internal ValidationResult ValidateChain(Mono.Security.X509.X509CertificateCollection certs)
{
bool flag = false;
if (certs == null || certs.Count == 0)
{
return null;
}
ICertificatePolicy certificatePolicy = ServicePointManager.CertificatePolicy;
global::System.Net.Security.RemoteCertificateValidationCallback serverCertificateValidationCallback = ServicePointManager.ServerCertificateValidationCallback;
global::System.Security.Cryptography.X509Certificates.X509Chain x509Chain = new global::System.Security.Cryptography.X509Certificates.X509Chain();
x509Chain.ChainPolicy = new global::System.Security.Cryptography.X509Certificates.X509ChainPolicy();
for (int i = 1; i < certs.Count; i++)
{
global::System.Security.Cryptography.X509Certificates.X509Certificate2 x509Certificate = new global::System.Security.Cryptography.X509Certificates.X509Certificate2(certs[i].RawData);
x509Chain.ChainPolicy.ExtraStore.Add(x509Certificate);
}
global::System.Security.Cryptography.X509Certificates.X509Certificate2 x509Certificate2 = new global::System.Security.Cryptography.X509Certificates.X509Certificate2(certs[0].RawData);
int num = 0;
global::System.Net.Security.SslPolicyErrors sslPolicyErrors = global::System.Net.Security.SslPolicyErrors.None;
try
{
if (!x509Chain.Build(x509Certificate2))
{
sslPolicyErrors |= ServicePointManager.ChainValidationHelper.GetErrorsFromChain(x509Chain);
}
}
catch (Exception ex)
{
Console.Error.WriteLine("ERROR building certificate chain: {0}", ex);
Console.Error.WriteLine("Please, report this problem to the Mono team");
sslPolicyErrors |= global::System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors;
}
if (!ServicePointManager.ChainValidationHelper.CheckCertificateUsage(x509Certificate2))
{
sslPolicyErrors |= global::System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors;
num = -2146762490;
}
if (!ServicePointManager.ChainValidationHelper.CheckServerIdentity(certs[0], this.Host))
{
sslPolicyErrors |= global::System.Net.Security.SslPolicyErrors.RemoteCertificateNameMismatch;
num = -2146762481;
}
bool flag2 = false;
try
{
Mono.Security.X509.OSX509Certificates.SecTrustResult secTrustResult = Mono.Security.X509.OSX509Certificates.TrustEvaluateSsl(certs);
flag2 = secTrustResult == Mono.Security.X509.OSX509Certificates.SecTrustResult.Proceed || secTrustResult == Mono.Security.X509.OSX509Certificates.SecTrustResult.Unspecified;
}
catch
{
}
if (flag2)
{
num = 0;
sslPolicyErrors = global::System.Net.Security.SslPolicyErrors.None;
}
if (certificatePolicy != null && (!(certificatePolicy is DefaultCertificatePolicy) || serverCertificateValidationCallback == null))
{
ServicePoint servicePoint = null;
HttpWebRequest httpWebRequest = this.sender as HttpWebRequest;
if (httpWebRequest != null)
{
servicePoint = httpWebRequest.ServicePoint;
}
if (num == 0 && sslPolicyErrors != global::System.Net.Security.SslPolicyErrors.None)
{
num = ServicePointManager.ChainValidationHelper.GetStatusFromChain(x509Chain);
}
flag2 = certificatePolicy.CheckValidationResult(servicePoint, x509Certificate2, httpWebRequest, num);
flag = !flag2 && !(certificatePolicy is DefaultCertificatePolicy);
}
if (serverCertificateValidationCallback != null)
{
flag2 = serverCertificateValidationCallback(this.sender, x509Certificate2, x509Chain, sslPolicyErrors);
flag = !flag2;
}
return new ValidationResult(flag2, flag, num);
}
// Token: 0x0600156B RID: 5483 RVA: 0x000446A8 File Offset: 0x000428A8
private static int GetStatusFromChain(global::System.Security.Cryptography.X509Certificates.X509Chain chain)
{
long num = 0L;
foreach (global::System.Security.Cryptography.X509Certificates.X509ChainStatus x509ChainStatus in chain.ChainStatus)
{
global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags status = x509ChainStatus.Status;
if (status != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NotTimeValid) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762495));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NotTimeNested) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762494));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.Revoked) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762484));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NotSignatureValid) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146869244));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NotValidForUsage) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762480));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.UntrustedRoot) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762487));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.RevocationStatusUnknown) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146885614));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.Cyclic) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762486));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.InvalidExtension) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762485));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.InvalidPolicyConstraints) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762483));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.InvalidBasicConstraints) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146869223));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.InvalidNameConstraints) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762476));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.HasNotSupportedNameConstraint) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762476));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.HasNotDefinedNameConstraint) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762476));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.HasNotPermittedNameConstraint) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762476));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.HasExcludedNameConstraint) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762476));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.PartialChain) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762486));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.CtlNotTimeValid) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762495));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.CtlNotSignatureValid) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146869244));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.CtlNotValidForUsage) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762480));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.OfflineRevocation) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146885614));
}
else if ((status & global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoIssuanceChainPolicy) != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
num = (long)((ulong)(-2146762489));
}
else
{
num = (long)((ulong)(-2146762485));
}
break;
}
}
return (int)num;
}
// Token: 0x0600156C RID: 5484 RVA: 0x00044910 File Offset: 0x00042B10
private static global::System.Net.Security.SslPolicyErrors GetErrorsFromChain(global::System.Security.Cryptography.X509Certificates.X509Chain chain)
{
global::System.Net.Security.SslPolicyErrors sslPolicyErrors = global::System.Net.Security.SslPolicyErrors.None;
foreach (global::System.Security.Cryptography.X509Certificates.X509ChainStatus x509ChainStatus in chain.ChainStatus)
{
if (x509ChainStatus.Status != global::System.Security.Cryptography.X509Certificates.X509ChainStatusFlags.NoError)
{
sslPolicyErrors |= global::System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors;
break;
}
}
return sslPolicyErrors;
}
// Token: 0x0600156D RID: 5485 RVA: 0x00044964 File Offset: 0x00042B64
private static bool CheckCertificateUsage(global::System.Security.Cryptography.X509Certificates.X509Certificate2 cert)
{
bool flag;
try
{
if (cert.Version < 3)
{
flag = true;
}
else
{
global::System.Security.Cryptography.X509Certificates.X509KeyUsageExtension x509KeyUsageExtension = (global::System.Security.Cryptography.X509Certificates.X509KeyUsageExtension)cert.Extensions["2.5.29.15"];
global::System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension x509EnhancedKeyUsageExtension = (global::System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension)cert.Extensions["2.5.29.37"];
if (x509KeyUsageExtension != null && x509EnhancedKeyUsageExtension != null)
{
if ((x509KeyUsageExtension.KeyUsages & ServicePointManager.ChainValidationHelper.s_flags) == global::System.Security.Cryptography.X509Certificates.X509KeyUsageFlags.None)
{
flag = false;
}
else
{
flag = x509EnhancedKeyUsageExtension.EnhancedKeyUsages["1.3.6.1.5.5.7.3.1"] != null || x509EnhancedKeyUsageExtension.EnhancedKeyUsages["2.16.840.1.113730.4.1"] != null;
}
}
else if (x509KeyUsageExtension != null)
{
flag = (x509KeyUsageExtension.KeyUsages & ServicePointManager.ChainValidationHelper.s_flags) != global::System.Security.Cryptography.X509Certificates.X509KeyUsageFlags.None;
}
else if (x509EnhancedKeyUsageExtension != null)
{
flag = x509EnhancedKeyUsageExtension.EnhancedKeyUsages["1.3.6.1.5.5.7.3.1"] != null || x509EnhancedKeyUsageExtension.EnhancedKeyUsages["2.16.840.1.113730.4.1"] != null;
}
else
{
global::System.Security.Cryptography.X509Certificates.X509Extension x509Extension = cert.Extensions["2.16.840.1.113730.1.1"];
if (x509Extension != null)
{
string text = x509Extension.NetscapeCertType(false);
flag = text.IndexOf("SSL Server Authentication") != -1;
}
else
{
flag = true;
}
}
}
}
catch (Exception ex)
{
Console.Error.WriteLine("ERROR processing certificate: {0}", ex);
Console.Error.WriteLine("Please, report this problem to the Mono team");
flag = false;
}
return flag;
}
// Token: 0x0600156E RID: 5486 RVA: 0x00044AF8 File Offset: 0x00042CF8
private static bool CheckServerIdentity(Mono.Security.X509.X509Certificate cert, string targetHost)
{
bool flag;
try
{
Mono.Security.X509.X509Extension x509Extension = cert.Extensions["2.5.29.17"];
if (x509Extension != null)
{
SubjectAltNameExtension subjectAltNameExtension = new SubjectAltNameExtension(x509Extension);
foreach (string text in subjectAltNameExtension.DNSNames)
{
if (ServicePointManager.ChainValidationHelper.Match(targetHost, text))
{
return true;
}
}
foreach (string text2 in subjectAltNameExtension.IPAddresses)
{
if (text2 == targetHost)
{
return true;
}
}
}
flag = ServicePointManager.ChainValidationHelper.CheckDomainName(cert.SubjectName, targetHost);
}
catch (Exception ex)
{
Console.Error.WriteLine("ERROR processing certificate: {0}", ex);
Console.Error.WriteLine("Please, report this problem to the Mono team");
flag = false;
}
return flag;
}
// Token: 0x0600156F RID: 5487 RVA: 0x00044C00 File Offset: 0x00042E00
private static bool CheckDomainName(string subjectName, string targetHost)
{
string text = string.Empty;
global::System.Text.RegularExpressions.Regex regex = new global::System.Text.RegularExpressions.Regex("CN\\s*=\\s*([^,]*)");
global::System.Text.RegularExpressions.MatchCollection matchCollection = regex.Matches(subjectName);
if (matchCollection.Count == 1 && matchCollection[0].Success)
{
text = matchCollection[0].Groups[1].Value.ToString();
}
return ServicePointManager.ChainValidationHelper.Match(targetHost, text);
}
// Token: 0x06001570 RID: 5488 RVA: 0x00044C68 File Offset: 0x00042E68
private static bool Match(string hostname, string pattern)
{
int num = pattern.IndexOf('*');
if (num == -1)
{
return string.Compare(hostname, pattern, true, CultureInfo.InvariantCulture) == 0;
}
if (num != pattern.Length - 1 && pattern[num + 1] != '.')
{
return false;
}
int num2 = pattern.IndexOf('*', num + 1);
if (num2 != -1)
{
return false;
}
string text = pattern.Substring(num + 1);
int num3 = hostname.Length - text.Length;
if (num3 <= 0)
{
return false;
}
if (string.Compare(hostname, num3, text, 0, text.Length, true, CultureInfo.InvariantCulture) != 0)
{
return false;
}
if (num == 0)
{
int num4 = hostname.IndexOf('.');
return num4 == -1 || num4 >= hostname.Length - text.Length;
}
string text2 = pattern.Substring(0, num);
return string.Compare(hostname, 0, text2, 0, text2.Length, true, CultureInfo.InvariantCulture) == 0;
}
// Token: 0x040011CD RID: 4557
private object sender;
// Token: 0x040011CE RID: 4558
private string host;
// Token: 0x040011CF RID: 4559
private static bool is_macosx = File.Exists("/System/Library/Frameworks/Security.framework/Security");
// Token: 0x040011D0 RID: 4560
private static global::System.Security.Cryptography.X509Certificates.X509KeyUsageFlags s_flags = global::System.Security.Cryptography.X509Certificates.X509KeyUsageFlags.KeyAgreement | global::System.Security.Cryptography.X509Certificates.X509KeyUsageFlags.KeyEncipherment | global::System.Security.Cryptography.X509Certificates.X509KeyUsageFlags.DigitalSignature;
}
}
}