简体   繁体   English

将根 CA 导入 MS Office

[英]Import root CA to MS Office

I've use Apache POI and my certificate to digitally sign a.docx document:我使用 Apache POI 和我的证书对 a.docx 文档进行数字签名:

@Override
public byte[] sign(byte[] content, List<X509Certificate> certChain, PrivateKey privateKey) throws Exception {
    OPCPackage pkg = OPCPackage.open(new ByteArrayInputStream(content));

    SignatureConfig signatureConfig = new SignatureConfig();
    signatureConfig.setKey(privateKey);
    signatureConfig.setSigningCertificateChain(certChain);
    signatureConfig.setOpcPackage(pkg);

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    SignatureInfo si = new SignatureInfo();
    si.setSignatureConfig(signatureConfig);
    si.confirmSignature();
    pkg.save(outputStream);

    IOUtils.closeQuietly(pkg);
    return outputStream.toByteArray();
}

certChain contains my certificate and a self-signed certificate (root CA) that is used to sign my certificate (the root CA is the issuer of my certificate). certChain 包含我的证书和用于签署我的证书的自签名证书(根 CA)(根 CA 是我的证书的颁发者)。 This code run perfectly and a get signed.docx file.此代码运行完美,并获得了一个已签名的 docx 文件。 But when I open it by Microsoft Word 2016, I get this message:但是当我用 Microsoft Word 2016 打开它时,我收到了这条消息:

在此处输入图像描述

在此处输入图像描述

I also sign PDF content with Apache PDFBox and when I open a signed PDF file by Acrobat Reader, I get similar issue, but it's easily to solve by adding root CA to the list of Trusted certificates inside Acrobat Reader.我还使用 Apache PDFBox 签署了 PDF 内容,当我打开 Acrobat Reader 签署的PDF文件时,我得到了类似的问题,但它很容易通过在 Acrobat Reader 中添加根 CA 来解决。 But in Microsoft Office, I can not see any similar option.但在 Microsoft Office 中,我看不到任何类似的选项。 How can I get MS Office to trust the root CA (or at least trust my certificate)?如何让 MS Office 信任根 CA(或至少信任我的证书)?

After installing the certificate, export it as a PFX file.安装证书后,将其导出为PFX文件。 The export has an option to attach the root CA.导出具有附加根 CA 的选项。 Then use the PFX file for signing.然后使用 PFX 文件进行签名。

Disclaimer: I haven't tried this with a self-signed root CA, so I don't know if Office will accept it.免责声明:我没有尝试过使用自签名根 CA,所以我不知道 Office 是否会接受它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM