public static bool doSecurityCheckOnMainThread(byte[][] rawCerts) { System.Threading.AutoResetEvent waitHandle = new System.Threading.AutoResetEvent(false); SSLVerificationJob toVerify = new SSLVerificationJob(rawCerts, waitHandle); lock (validatorQueue) { validatorQueue.Enqueue(toVerify); } waitHandle.WaitOne(); return(toVerify.certIsValid); }
static IEnumerator pollForVerificationJobs() { for (;;) { yield return(null); while (validatorQueue.Count > 0) { SSLVerificationJob toVerify = null; lock (validatorQueue) { toVerify = validatorQueue.Dequeue(); } AndroidJavaObject fallbackCommunicator = new AndroidJavaObject("FallbackAndroidHTTPService"); for (int i = 0; i < toVerify.certs.Length; i++) { fallbackCommunicator.Call("AddCert", toVerify.certs [i]); } toVerify.certIsValid = fallbackCommunicator.Call <bool> ("CheckCertificates"); toVerify.waitHandle.Set(); //signal processing is done } } }