| | |
| | | using System.Net;
|
| | | using System.Text;
|
| | | using System.IO;
|
| | | using System.Net.Security;
|
| | | using System.Security.Cryptography.X509Certificates;
|
| | |
|
| | | public class HttpBehaviour : MonoBehaviour
|
| | | {
|
| | |
| | | request.ReadWriteTimeout = 2000;
|
| | | request.Proxy = null;
|
| | | request.KeepAlive = false;
|
| | | ServicePointManager.ServerCertificateValidationCallback += RemoteCertificateValidationCallback;
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | |
| | |
|
| | | }
|
| | |
|
| | | private static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
|
| | | {
|
| | | if (sslPolicyErrors == SslPolicyErrors.None)
|
| | | return true;
|
| | |
|
| | | var _acceptCertificate = true;
|
| | |
|
| | | if ((sslPolicyErrors &
|
| | | SslPolicyErrors.RemoteCertificateNotAvailable) == SslPolicyErrors.RemoteCertificateNotAvailable)
|
| | | {
|
| | | _acceptCertificate = false;
|
| | | }
|
| | | else
|
| | | {
|
| | | if ((sslPolicyErrors &
|
| | | SslPolicyErrors.RemoteCertificateNameMismatch) == SslPolicyErrors.RemoteCertificateNameMismatch)
|
| | | {
|
| | | _acceptCertificate = false;
|
| | | }
|
| | |
|
| | | if ((sslPolicyErrors &
|
| | | SslPolicyErrors.RemoteCertificateChainErrors) == SslPolicyErrors.RemoteCertificateChainErrors)
|
| | | {
|
| | | foreach (X509ChainStatus item in chain.ChainStatus)
|
| | | {
|
| | | if (item.Status != X509ChainStatusFlags.RevocationStatusUnknown &&
|
| | | item.Status != X509ChainStatusFlags.OfflineRevocation)
|
| | | break;
|
| | |
|
| | | if (item.Status != X509ChainStatusFlags.NoError)
|
| | | {
|
| | | _acceptCertificate = false;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (_acceptCertificate == false)
|
| | | {
|
| | | _acceptCertificate = true;
|
| | | }
|
| | |
|
| | | return _acceptCertificate;
|
| | | }
|
| | | void Update()
|
| | | {
|
| | | if (Time.time > timeOut && !getResult)
|