public virtual byte[] GetEncoded(X509Certificate checkCert, X509Certificate issuerCert, String url)
 {
     byte[] bytes = null;
     try {
         CertificateID id = SignTestPortUtil.GenerateCertificateId(issuerCert, checkCert.SerialNumber, Org.BouncyCastle.Ocsp.CertificateID.HashSha1
                                                                   );
         bytes = builder.MakeOcspResponse(SignTestPortUtil.GenerateOcspRequestWithNonce(id).GetEncoded(), caPrivateKey
                                          );
     }
     catch (Exception) {
     }
     return(bytes);
 }
        /// <exception cref="Org.BouncyCastle.Security.GeneralSecurityException"/>
        /// <exception cref="System.IO.IOException"/>
        private bool VerifyTest(TestCrlBuilder crlBuilder)
        {
            String            caCertFileName    = certsSrc + "rootRsa.p12";
            X509Certificate   caCert            = (X509Certificate)Pkcs12FileHelper.ReadFirstChain(caCertFileName, password)[0];
            ICipherParameters caPrivateKey      = Pkcs12FileHelper.ReadFirstKey(caCertFileName, password, password);
            String            checkCertFileName = certsSrc + "signCertRsa01.p12";
            X509Certificate   checkCert         = (X509Certificate)Pkcs12FileHelper.ReadFirstChain(checkCertFileName, password)[
                0];
            TestCrlClient        crlClient          = new TestCrlClient(crlBuilder, caPrivateKey);
            ICollection <byte[]> crlBytesCollection = crlClient.GetEncoded(checkCert, null);
            bool verify = false;

            foreach (byte[] crlBytes in crlBytesCollection)
            {
                X509Crl     crl      = (X509Crl)SignTestPortUtil.ParseCrlFromStream(new MemoryStream(crlBytes));
                CRLVerifier verifier = new CRLVerifier(null, null);
                verify = verifier.Verify(crl, checkCert, caCert, DateTimeUtil.GetCurrentUtcTime());
                break;
            }
            return(verify);
        }
Exemple #3
0
 public virtual byte[] GetEncoded(X509Certificate checkCert, X509Certificate issuerCert, String url)
 {
     byte[] bytes = null;
     try {
         CertificateID id = SignTestPortUtil.GenerateCertificateId(issuerCert, checkCert.SerialNumber, Org.BouncyCastle.Ocsp.CertificateID.HashSha1
                                                                   );
         TestOcspResponseBuilder builder = issuerIdToResponseBuilder.Get(issuerCert.SerialNumber.ToString(16));
         if (builder == null)
         {
             throw new ArgumentException("This TestOcspClient instance is not capable of providing OCSP response for the given issuerCert:"
                                         + issuerCert.SubjectDN.ToString());
         }
         bytes = builder.MakeOcspResponse(SignTestPortUtil.GenerateOcspRequestWithNonce(id).GetEncoded());
     }
     catch (Exception ignored) {
         if (ignored is Exception)
         {
             throw (Exception)ignored;
         }
     }
     return(bytes);
 }
Exemple #4
0
 /// <exception cref="Org.BouncyCastle.Security.GeneralSecurityException"/>
 public virtual IDigest GetMessageDigest()
 {
     return(SignTestPortUtil.GetMessageDigest(DIGEST_ALG));
 }