예제 #1
0
 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);
 }
예제 #2
0
 public void setPinset(IPinset pinset)
 {
     this.pinset = pinset;
 }
예제 #3
0
        public bool ServerCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
        {
            IPinset pinset = ((ThreadedHTTPFactory)getClient().getFactory()).getPinset();

            return(ThreadSafeValidateCertificate(pinset, (HttpWebRequest)sender, certificate, sslPolicyErrors));
        }
예제 #4
0
 public void loadDefaultPinset()
 {
     defaultPinset = new AssetPinset("pinset", getParser());
 }
예제 #5
0
 protected void setPinset(IPinset pinset)
 {
     this.pinset = pinset;
 }
예제 #6
0
        protected ThreadedHTTPFactory()
        {
            IPinsetFactory pinsetFactory = DefaultPinsetFactory.getFactory();

            pinset = pinsetFactory.getPinset();
        }