Example #1
0
        public static void Main(String[] args) {
            Properties properties = new Properties();
            properties.Load(new FileStream("c:/home/blowagie/key.properties", FileMode.Open));
            String path = properties["PRIVATE"];
            char[] pass = properties["PASSWORD"].ToCharArray();

            Pkcs12Store ks = new Pkcs12Store();
            ks.Load(new FileStream(path, FileMode.Open), pass);
            String alias = "";
            foreach (string al in ks.Aliases) {
                if (ks.IsKeyEntry(al) && ks.GetKey(al).Key.IsPrivate) {
                    alias = al;
                    break;
                }
            }
            AsymmetricKeyParameter pk = ks.GetKey(alias).Key;
            ICollection<X509Certificate> chain = new List<X509Certificate>();
            foreach (X509CertificateEntry entry in ks.GetCertificateChain(alias)) {
                chain.Add(entry.Certificate);
            }
            IOcspClient ocspClient = new OcspClientBouncyCastle();
            C3_01_SignWithCAcert.Sign(DEST, chain, pk, DigestAlgorithms.SHA256, CryptoStandard.CMS, "Test", "Ghent",
                     null, ocspClient, null, 0);
        }
Example #2
0
        /**
         * Gets an OCSP response online and returns it if the status is GOOD
         * (without further checking).
         * @param signCert	the signing certificate
         * @param issuerCert	the issuer certificate
         * @return an OCSP response
         */
        virtual public BasicOcspResp GetOcspResponse(X509Certificate signCert, X509Certificate issuerCert)
        {
            if (signCert == null && issuerCert == null)
            {
                return(null);
            }
            OcspClientBouncyCastle ocsp     = new OcspClientBouncyCastle();
            BasicOcspResp          ocspResp = ocsp.GetBasicOCSPResp(signCert, issuerCert, null);

            if (ocspResp == null)
            {
                return(null);
            }
            SingleResp[] resp = ocspResp.Responses;
            for (int i = 0; i < resp.Length; ++i)
            {
                Object status = resp[i].GetCertStatus();
                if (status == CertificateStatus.Good)
                {
                    return(ocspResp);
                }
            }
            return(null);
        }
Example #3
0
	    /**
	     * Gets an OCSP response online and returns it if the status is GOOD
	     * (without further checking).
	     * @param signCert	the signing certificate
	     * @param issuerCert	the issuer certificate
	     * @return an OCSP response
	     */
	    public BasicOcspResp GetOcspResponse(X509Certificate signCert, X509Certificate issuerCert) {
		    if (signCert == null && issuerCert == null) {
			    return null;
		    }
		    OcspClientBouncyCastle ocsp = new OcspClientBouncyCastle();
		    BasicOcspResp ocspResp = ocsp.GetBasicOCSPResp(signCert, issuerCert, null);
		    if (ocspResp == null) {
			    return null;
		    }
		    SingleResp[] resp = ocspResp.Responses;
		    for (int i = 0; i < resp.Length; ++i) {
			    Object status = resp[i].GetCertStatus();
			    if (status == CertificateStatus.Good) {
				    return ocspResp;
			    }
		    }
		    return null;
	    }
 public SignatureSettings()
 {
     OcspClient = new OcspClientBouncyCastle();
 }