/** * Set OCSP responder cert. * @param x509 certificate that was used identify OCSP responder */ void digidoc::SignatureTM::setOCSPCertificate(const X509Cert& x509) { //XXX: copied from digidoc::Signature::setSigningCertificate DEBUG("digidoc::SignatureTM::setOCSPCertificate()"); std::vector<unsigned char> derEncodedX509 = x509.encodeDER(); // Calculate SHA1 digest of the certificate. std::auto_ptr<Digest> calc = Digest::create(); calc->update(derEncodedX509); dsig::DigestMethodType digestMethod(xml_schema::Uri(calc->getUri())); dsig::DigestValueType digestValue(xml_schema::Base64Binary(&calc->getDigest()[0], calc->getSize())); xades::DigestAlgAndValueType certDigest(digestMethod, digestValue); // Add certificate issuer info. dsig::X509IssuerSerialType issuerSerial(xml_schema::String(x509.getIssuerName()), xml_schema::Integer(x509.getSerial())); digidoc::xades::CertIDType cert(certDigest, issuerSerial); xades::CertIDListType certList; certList.cert().push_back(cert); xades::CompleteCertificateRefsType certificateRefs(certList); //certificateRefs.certRefs(certList); unsignedSignatureProperties()->completeCertificateRefs().push_back(certificateRefs); //CertificateValues addCertificateValue(std::string("S0-RESPONDER_CERT"), x509); }
/** * Add certificate under CertificateValues element * @param certId id attribute of EncapsulatedX509Certificate * @param x509 value of EncapsulatedX509Certificate */ void digidoc::SignatureTM::addCertificateValue(const std::string& certId, const X509Cert& x509) { DEBUG("digidoc::SignatureTM::setCertificateValue(%s, X509Cert{%ld,%s})", certId.c_str(), x509.getSerial(), x509.getSubject().c_str()); //CertificateValues std::vector<unsigned char> certBytes = x509.encodeDER(); xades::CertificateValuesType::EncapsulatedX509CertificateType certData( xml_schema::Base64Binary(&certBytes[0], certBytes.size())); certData.id(xml_schema::Id(certId.c_str())); unsignedSignatureProperties()->certificateValues()[0].encapsulatedX509Certificate().push_back(certData); }