Crypto functions analysis in SCEP client java version

来源:互联网 发布:linux复制压缩文件命令 编辑:程序博客网 时间:2024/06/03 23:04
    /**     * Generate an PKCS#10 request based on the past in signer.     *     * @param signer the content signer to be used to generate the signature validating the certificate.     * @return a holder containing the resulting PKCS#10 certification request.     */    public PKCS10CertificationRequest build(        ContentSigner signer)    {        CertificationRequestInfo info;        if (attributes.isEmpty())        {            if (leaveOffEmpty)            {                info = new CertificationRequestInfo(subject, publicKeyInfo, null);            }            else            {                info = new CertificationRequestInfo(subject, publicKeyInfo, new DERSet());            }        }        else        {            ASN1EncodableVector v = new ASN1EncodableVector();            for (Iterator it = attributes.iterator(); it.hasNext();)            {                v.add(Attribute.getInstance(it.next()));            }            info = new CertificationRequestInfo(subject, publicKeyInfo, new DERSet(v));        }        try        {            OutputStream sOut = signer.getOutputStream();            sOut.write(info.getEncoded(ASN1Encoding.DER));            sOut.close();            return new PKCS10CertificationRequest(new CertificationRequest(info, signer.getAlgorithmIdentifier(), new DERBitString(signer.getSignature())));        }        catch (IOException e)        {            throw new IllegalStateException("cannot produce certification request signature");        }    }}

0 0
原创粉丝点击