public static bool AddSslCertificate(byte[] certificateHash, byte[] encodedCert)
        {
            if (CertificateStorageManager.IsSSLCertificateAddedBefore(certificateHash))
            {
                return(false);
            }

            Certificate sslCertificate = CertificateParser.Parse(encodedCert);

            if (!sslCertificate.IsLoaded)
            {
                return(false);
            }

            if (!CertificateValidator.CheckValidityPeriod(sslCertificate))
            {
                return(false);
            }

            if (!CertificateValidator.ValidateSslCertificateFields(sslCertificate))
            {
                return(false);
            }

            if (!CertificateChainValidator.ValidateCertificateSignatureWithChain(sslCertificate))
            {
                return(false);
            }

            CertificateStorageManager.AddEndEntityCertificateToStorage(sslCertificate, certificateHash, encodedCert);
            return(true);
        }
        public static bool AddSslCertificate(byte[] certificateHash, byte[] encodedCert)
        {
            Logger.log("Checking SSL Certificate is added before");
            if (CertificateStorageManager.IsSSLCertificateAddedBefore(certificateHash))
            {
                Logger.log("SSL Certificate is added before");
                return(false);
            }

            Logger.log("Trying to parse SSL Certificate");
            Certificate sslCertificate = CertificateParser.Parse(encodedCert);

            if (!sslCertificate.IsLoaded)
            {
                Logger.log("Can not parse SSL Certificate");
                return(false);
            }

            Logger.log("Checking SSL Certificate Validity Period");
            if (!CertificateValidator.CheckValidityPeriod(sslCertificate))
            {
                Logger.log("SSL Certificate validity period is invalid");
                return(false);
            }

            Logger.log("Checking SSL Certificate Fields");
            if (!CertificateValidator.ValidateSslCertificateFields(sslCertificate))
            {
                Logger.log("SSL Certificate Fields are invalid");
                return(false);
            }

            Logger.log("Validating SSL Certificate With Chain");
            if (!CertificateChainValidator.ValidateCertificateSignatureWithChain(sslCertificate))
            {
                Logger.log("Can not validate SSL Certificate Signature With Chain");
                return(false);
            }

            Logger.log("Adding SSL Certificate To Storage");
            CertificateStorageManager.AddEndEntityCertificateToStorage(sslCertificate, certificateHash, encodedCert);
            return(true);
        }