public static bool RevokeSubCaCertificate(byte[] certificateHash, byte[] encodedCert, byte[] signature) { if (!CertificateStorageManager.IsSubCaCertificateAddedBefore(certificateHash)) { return(false); } Certificate subCaCertificate = CertificateParser.Parse(encodedCert); if (!subCaCertificate.IsLoaded) { Logger.log("Can not parse Sub CA Certificate"); return(false); } if (!ValidateRevokeSubCaCertificateRequestSignature(subCaCertificate, signature)) { return(false); } if (!CertificateValidator.CheckValidityPeriod(subCaCertificate)) { return(false); } if (!CertificateStorageManager.MarkSubCaCertificateRevokedInStorage(subCaCertificate, certificateHash)) { return(false); } return(true); }
public static bool RevokeSslCertificate(byte[] certificateHash, byte[] encodedCert, byte[] signature) { Logger.log("Checking SSL Certificate is added before"); if (!CertificateStorageManager.IsSSLCertificateAddedBefore(certificateHash)) { Logger.log("SSL Certificate is not added before"); return(false); } Certificate sslCertificate = CertificateParser.Parse(encodedCert); if (!sslCertificate.IsLoaded) { Logger.log("Can not parse SSL Certificate"); return(false); } if (!ValidateRevokeSslCertificateRequestSignature(sslCertificate, signature)) { Logger.log("SSL Certificate revoke request signature is invalid"); return(false); } if (!CertificateStorageManager.MarkEndEntityCertificateRevokedInStorage(certificateHash)) { Logger.log("Error while marking as remoked SSL Certificate in Storage"); return(false); } return(true); }
public static bool AddSubCaCertificate(byte[] certificateHash, byte[] encodedCert, byte[] signature) { if (CertificateStorageManager.IsSubCaCertificateAddedBefore(certificateHash)) { Logger.log("Sub CA Certificate is added before"); return(false); } Certificate subCaCertificate = CertificateParser.Parse(encodedCert); if (!subCaCertificate.IsLoaded) { Logger.log("Can not parse Sub CA Certificate"); return(false); } if (!ValidateSubCaCertificateAddRequestSignature(subCaCertificate, signature)) { Logger.log("Can not validate Add Sub CA Certificate request signature"); return(false); } if (!CertificateValidator.ValidateSubCaCertificate(subCaCertificate)) { Logger.log("Can not validate Sub CA Certificate"); return(false); } CertificateStorageManager.AddSubCaCertificateToStorage(subCaCertificate, certificateHash, encodedCert); return(true); }
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 AddTrustedRootCaCertificate(byte[] certificateHash, byte[] encodedCert, byte[] signature) { if (!ValidateRootCaCertificateAddRequestSignature(encodedCert, signature)) { return(false); } if (CertificateStorageManager.IsRootCaCertificateAddedBefore(certificateHash)) { return(false); } Certificate rootCaCertificate = CertificateParser.Parse(encodedCert); if (!rootCaCertificate.IsLoaded) { return(false); } if (!CertificateValidator.ValidateRootCaCertificate(rootCaCertificate)) { return(false); } CertificateStorageManager.AddRootCaCertificateToStorage(rootCaCertificate, certificateHash, encodedCert); return(true); }
public static bool UntrustRootCaCertificate(byte[] certificateHash, byte[] encodedCert, byte[] signature) { if (!ValidateUntrustRootCaCertificateRequestSignature(encodedCert, signature)) { Logger.log("Error while validating Untrust Root Ca Certificate Request"); return(false); } if (!CertificateStorageManager.IsRootCaCertificateAddedBefore(certificateHash)) { Logger.log("Untrust error. Root CA is not added before"); return(false); } Certificate rootCaCertificate = CertificateParser.Parse(encodedCert); if (!rootCaCertificate.IsLoaded) { Logger.log("Error while parsing encoded root CA content"); return(false); } CertificateStorageManager.MarkRootCaCertificateUntrustedInStorage(rootCaCertificate, certificateHash); return(true); }
public static object LogTrustedCAList() { CertificateHashEntry[] retrieveTrustedRootCaList = CertificateStorageManager.RetrieveTrustedRootCaList(); Logger.log(retrieveTrustedRootCaList.Length); foreach (CertificateHashEntry certificateHashEntry in retrieveTrustedRootCaList) { Logger.log(" "); Logger.log(certificateHashEntry.CertificateHash); Logger.log(certificateHashEntry.IsCa); Logger.log(" "); } return(true); }
public static bool UntrustRootCaCertificate(byte[] certificateHash, byte[] encodedCert, byte[] signature) { if (!ValidateRootCaCertificateAddRequestSignature(encodedCert, signature)) { return(false); } if (!CertificateStorageManager.IsRootCaCertificateAddedBefore(certificateHash)) { return(false); } Certificate rootCaCertificate = CertificateParser.Parse(encodedCert); CertificateStorageManager.MarkRootCaCertificateUntrustedInStorage(rootCaCertificate, certificateHash); return(true); }
public void ProcessPFXTest() { var pfxName = Environment.GetEnvironmentVariable("TEMP") + "\\test_tmp.pfx"; var pfxPwd = "test"; var testPfx = "MIII4QIBAzCCCKcGCSqGSIb3DQEHAaCCCJgEggiUMIIIkDCCA0cGCSqGSIb3DQEHBqCCAzgwggM0AgEAMIIDLQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIA8LIxLUYVCsCAggAgIIDAMjaS/s4uR/FK7lYpSBe3QamT5HUbXWiKgxRlM1NbuGpICN9JIFuejxKmumBkEoFF/Jg+5XKZGAKKdiVG72kWwsY6D8T3WUcN8If9s2HacSBbsyeZ712OoOnh9vyyqu0TtQ5Z8BOPzO2tJImd05j4hZ3t/EO35vmeMdOM5BA6SS9TJ11E2cZuc2ARQlfIquW9yrQW+FmwFuVG6aqNXZA9c4YjQHn1xifuZ8HFZsSQpuG5KZQzOTUEivMtn7Ct7UK9MAlK7nQblxtpW5iYGpWxsrfh0GXp7+8olOY3dm8iHqwyoPoXEOVjnZPxOEn2dg9oJT3TOvcO85jwM3CkeyvPkzJeStqz2n1xFipETr7WRDekK0j7Z4qDmP6VZA0B3C4+91Occ0kKJDPtsHAUTMpkyhMTZEXCbFT1R8gfiOhFeWLzd4cOsTiUSpXSk9oG68kJ3uEaP0uXUH9eNVRXeHthGlxbl71AxkeOJa4nP8Fot5ZLaXYg8CWQ4NnC4YITBMdoBiiYKNwsPCJBiEueiuEB5puO/NS+ZOO346COxtalX8a1PKShFNw3bCvaHg54jIMsrPNy0K6mpas/h4u8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oC+Ckho5xpcPSBmGMSUwIwYJKoZIhvcNAQkVMRYEFNPHWcwMABpZYlB+Bl74m8ceTJwmMDEwITAJBgUrDgMCGgUABBRIYzYkD++kAMXAxtTQ9+DDCK9LKAQIAK8dKmYIyIICAggA"; byte[] data = Convert.FromBase64String(testPfx); File.WriteAllBytes(pfxName, data); AuthenticatedPFX aPfx = new AuthenticatedPFX(pfxName, pfxPwd); CertificateStorageManager certMgr = new CertificateStorageManager(aPfx, true); try { certMgr.ProcessPFX(); } catch (Exception e) { Console.WriteLine(e); Assert.Fail(); } }
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); }
public static bool ReportFraud(byte[] fraudId, byte[] fakeButValidCertificateBytes, byte[] fakeButValidCertificateHash, byte[] signerCertificateBytes, byte[] signerCertificateBytesHash, byte[] signature) { Certificate fakeButValidCertificate = CertificateParser.Parse(fakeButValidCertificateBytes); if (!fakeButValidCertificate.IsLoaded) { Logger.log("Can not parse Fake But Valid SSL Certificate"); return(false); } EndEntityCertificateEntry fakeButValidCertificateEntry = CertificateStorageManager.RetrieveEndEntityCertificateFromStorage(fakeButValidCertificateHash); if (fakeButValidCertificateEntry.CertificateValue == null) { Logger.log("Can not find Fake But Valid SSL Certificate"); return(false); } if (fakeButValidCertificateEntry.IsRevoked) { Logger.log("Fake But Valid SSL Certificate is revoked before"); return(false); } Certificate signerCertificate = CertificateParser.Parse(signerCertificateBytes); if (!signerCertificate.IsLoaded) { Logger.log("Can not parse Signer Certificate"); return(false); } var signerCertificateContainFakeButValidCertificateDnsEntry = checkDnsValues(fakeButValidCertificate, signerCertificate); if (!signerCertificateContainFakeButValidCertificateDnsEntry) { Logger.log("Signer Certificate Does not contain required DNS value"); return(false); } Logger.log("Starting Validate Signature For Report Fraud Request"); bool signatureValidationResult = SignatureValidator.CheckReportFraudRequestSignature(signature, fakeButValidCertificate, signerCertificate); if (!signatureValidationResult) { Logger.log("Report Fraud Request signature Invalid"); return(false); } Logger.log("Validated Signature For Report Fraud Request"); FraudStorageManager.AddFraudReportToStorage(fraudId, signerCertificateBytes, fakeButValidCertificateHash); //todo: add fraud notification after log infrastructure fixed return(true); }