Skip to content

Commit

Permalink
Merge branch 'develop' into devsecops
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Jun 21, 2024
2 parents b73d730 + 12bf187 commit f43b1f0
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,58 @@ public virtual void ShortValidityCertsWithCrlTest() {
).WithMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, (i) => tsRootCert.GetSubjectDN())));
}

[NUnit.Framework.Test]
public virtual void RetrieveRevocationDataFromTheSignatureContainerTest() {
String rootCertName = CERTS_SRC + "rootRsa.pem";
IX509Certificate rootCert = (IX509Certificate)PemFileHelper.ReadFirstChain(rootCertName)[0];
// We need to set infinite freshness for the signature validation. Otherwise, test will fail.
builder.GetProperties().SetFreshness(ValidatorContexts.Of(ValidatorContext.OCSP_VALIDATOR, ValidatorContext
.CRL_VALIDATOR), CertificateSources.Of(CertificateSource.SIGNER_CERT), TimeBasedContexts.Of(TimeBasedContext
.PRESENT), TimeSpan.FromDays(999999));
ValidationReport report;
// Signature container stores OCSP response with indeterminate status and less fresh but valid CRL response.
using (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "revDataInTheSignatureContainer.pdf"
))) {
certificateRetriever.SetTrustedCertificates(JavaCollectionsUtil.SingletonList(rootCert));
SignatureValidator signatureValidator = builder.BuildSignatureValidator();
report = signatureValidator.ValidateSignatures(document);
}
AssertValidationReport.AssertThat(report, (a) => a.HasStatus(ValidationReport.ValidationResult.VALID).HasNumberOfLogs
(4).HasNumberOfFailures(0).HasLogItem((al) => al.WithCheckName(SignatureValidator.SIGNATURE_VERIFICATION
).WithMessage(SignatureValidator.VALIDATING_SIGNATURE_NAME, (i) => "Signature1")).HasLogItem((al) => al
.WithCheckName(OCSPValidator.OCSP_CHECK).WithMessage(OCSPValidator.CERT_STATUS_IS_UNKNOWN).WithStatus(
ReportItem.ReportItemStatus.INFO)).HasLogItems(2, (al) => al.WithCertificate(rootCert).WithCheckName(CertificateChainValidator
.CERTIFICATE_CHECK).WithMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, (i) => rootCert.GetSubjectDN
())));
}

[NUnit.Framework.Test]
public virtual void RetrieveRevocationDataStoredInTheSignerInfoTest() {
String rootCertName = CERTS_SRC + "rootRsa.pem";
IX509Certificate rootCert = (IX509Certificate)PemFileHelper.ReadFirstChain(rootCertName)[0];
// We need to set infinite freshness for the embedded timestamp validation. Otherwise, test will fail.
builder.GetProperties().SetFreshness(ValidatorContexts.Of(ValidatorContext.OCSP_VALIDATOR, ValidatorContext
.CRL_VALIDATOR), CertificateSources.Of(CertificateSource.TIMESTAMP), TimeBasedContexts.Of(TimeBasedContext
.PRESENT), TimeSpan.FromDays(999999)).SetFreshness(ValidatorContexts.Of(ValidatorContext.CRL_VALIDATOR
), CertificateSources.Of(CertificateSource.SIGNER_CERT), TimeBasedContexts.Of(TimeBasedContext.HISTORICAL
), TimeSpan.FromDays(2));
ValidationReport report;
// Signer info authenticated attributes store OCSP response with indeterminate status and valid CRL response.
using (PdfDocument document = new PdfDocument(new PdfReader(SOURCE_FOLDER + "revDataInTheSignerInfo.pdf"))
) {
certificateRetriever.SetTrustedCertificates(JavaCollectionsUtil.SingletonList(rootCert));
SignatureValidator signatureValidator = builder.BuildSignatureValidator();
report = signatureValidator.ValidateSignatures(document);
}
AssertValidationReport.AssertThat(report, (a) => a.HasStatus(ValidationReport.ValidationResult.VALID).HasNumberOfLogs
(6).HasNumberOfFailures(0).HasLogItem((al) => al.WithCheckName(SignatureValidator.SIGNATURE_VERIFICATION
).WithMessage(SignatureValidator.VALIDATING_SIGNATURE_NAME, (i) => "Signature1")).HasLogItem((al) => al
.WithCheckName(OCSPValidator.OCSP_CHECK).WithMessage(OCSPValidator.CERT_STATUS_IS_UNKNOWN).WithStatus(
ReportItem.ReportItemStatus.INFO)).HasLogItems(4, (al) => al.WithCertificate(rootCert).WithCheckName(CertificateChainValidator
.CERTIFICATE_CHECK).WithMessage(CertificateChainValidator.CERTIFICATE_TRUSTED, (i) => rootCert.GetSubjectDN
())));
}

[NUnit.Framework.Test]
public virtual void LatestSignatureIsTimestampTest() {
String chainName = CERTS_SRC + "validCertsChain.pem";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIFNTBfBgkqhkiG9w0BBQ0wUjAxBgkqhkiG9w0BBQwwJAQQed2OhiJqKregwesf
Q7qbJAICCAAwDAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEEGezm1YV51PeoC8M
MG+1yVcEggTQqO38B271mogM524SNQRRAhqoY7bw5c1G+O6iKJk08VkA82R42OpV
DndjibcLuC+JxkbxGD55MDKV3xfYa3c6dYCTPJ/yqx3XK2eRkRVvbAEAO+3JgNeh
lSRffQklSyjj4n9tVZNaaCfeEJMVj5yZWEc4K8l8ddNOMMx7qK9qedBG4nfNVqkX
cAZycTPUuDIgA8Q6GLHNjDgxwOsi0L5LsGsWI0yY02dTcU5lS04/xyT850xIfkkn
si5QBahVRJLQCFxa2Abl8zzpTIBScVICNlcXLlpPJfEAAwP7/ksaMvAnPDS0GeR9
5CBjeHznUJDjODubbrGg64uij4eTe5MrMQKcjNIl8UhN9Fy/W/SCehS+Dc/1d3Xf
cyuigeI01+d1FxzTXslL91PToyehSXcyykBPd69tDv/R7Zk8D4ouVOX4YXiSnnA+
WiuuLyXQU9ABlEkQrTWftcEgYbJqIcjUHku6CApGQnTgD300zoAm37BY7x15oJ/T
reAs7Bf+bv68xvJUh9aOOvqcJdzhDeR59CZFOu6q6wTZTSoJeqTRVXIxGsH36Kna
Hgl4nipmIqkGI7fRMfHL7k4DTcSEC8FFBdzUqAqShj2qxxb7LTFUs4N45diAEhzo
AqEDXe80o2xBZZwkLLilLrH3BGCQiBH5ow8wl7G3v5fFXmeQfaEQGbmGM0p3pk9A
SfcKpdzgYDBH9Oc/I3b6LL+Lpfd74kNVq3s8GGkKFVP84Tlm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4
Ul+FEt/VuEW1NfPZm1U5ixMOrBfn0C8pxIX4+VSHN9I8WoFjSfYX4Y3ldRLTeqxQ
rhZQlbhGNymp3Kcvtuq5At6vopskyB8Q1b7L4e+hRWK2prz/7p4Bdhu2TmkEfWZc
YKpgrkVFqa/Z1uZ0q4KVBOP3cyaQmqRXTV37SfpNyHAJdol5ueF68VVVNZFRXw==
-----END CERTIFICATE-----
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit f43b1f0

Please sign in to comment.