public static bool ThreadSafeValidateCertificate(IPinset pinset, HttpWebRequest httpWebRequest, X509Certificate certificate, SslPolicyErrors sslPolicyErrors) { try { RequestDigestSet requestDigestSet = new RequestDigestSet(); if (requestDigestSet.ValidateCertificate(certificate, sslPolicyErrors)) { if (pinset == null) { return(sslPolicyErrors == SslPolicyErrors.None); } string text = httpWebRequest.RequestUri.ToString(); IList <IPinningInfo> pinningInfo = pinset.getPinningInfo(text); bool result = true; if (pinningInfo != null) { foreach (IPinningInfo item in pinningInfo) { if (verified(item, requestDigestSet)) { return(true); } if (item.getMode() != PinningMode.ADVISORY) { result = false; } } return(result); } UnityEngine.Debug.LogError("The URL '" + text + "' does not match any patterns in the certificate pinset file. The certificate it is presenting will not be trusted."); } } catch (Exception ex) { Console.WriteLine(ex.Message); UnityEngine.Debug.LogException(ex); } return(false); }
public void setPinset(IPinset pinset) { this.pinset = pinset; }
public bool ServerCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { IPinset pinset = ((ThreadedHTTPFactory)getClient().getFactory()).getPinset(); return(ThreadSafeValidateCertificate(pinset, (HttpWebRequest)sender, certificate, sslPolicyErrors)); }
public void loadDefaultPinset() { defaultPinset = new AssetPinset("pinset", getParser()); }
protected void setPinset(IPinset pinset) { this.pinset = pinset; }
protected ThreadedHTTPFactory() { IPinsetFactory pinsetFactory = DefaultPinsetFactory.getFactory(); pinset = pinsetFactory.getPinset(); }