繁体   English   中英

如何将签名的OCSP RESPONSE参数添加到ASN1 PKCS7

How to add a signed OCSP RESPONSE parameter to an ASN1 PKCS7

提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供   中文繁体   英文版本   中英对照 版本,有任何建议请联系yoyou2525@163.com。

参与字符串的签名。 通常的签名通过。 现在必须添加签名的参数。

添加行没有问题:

void add_signed_printable_string(PKCS7_SIGNER_INFO *si, char *oid, char *str)
{
    ASN1_PRINTABLESTRING *os;

    signed_string_nid = OBJ_create(oid, str, str);

    os=ASN1_PRINTABLESTRING_new();
    M_ASN1_OCTET_STRING_set(os,(unsigned char*)str,strlen(str));

    PKCS7_add_signed_attribute(si,signed_string_nid, V_ASN1_PRINTABLESTRING,(char *)os);
}

通过添加内容类型,一切也变得很清楚:

PKCS7_add_attrib_content_type(si, OBJ_nid2obj(OID_SIGNED_CONTENT_TYPE));

但是现在您需要添加一个对象X509_NAMEOCSP响应。

通常如何正确添加此类对象?

我试图通过手动记录所有参数来添加X509_NAME ,但这需要很长时间。

您应该得到类似以下内容(与1.3.6.1.4.1.6801.2.8和1.3.6.1.5.5.7.48.1.1相同):

       [0] (7 elem)
        SEQUENCE (2 elem)
          OBJECT IDENTIFIER 1.2.840.113549.1.9.13 signingDescription (PKCS #9)
          SET (1 elem)
            PrintableString ESEDO
        SEQUENCE (2 elem)
          OBJECT IDENTIFIER 1.2.840.113549.1.9.3 contentType (PKCS #9)
          SET (1 elem)
            OBJECT IDENTIFIER 1.2.840.113549.1.7.1 data (PKCS #7)
        SEQUENCE (2 elem)
          OBJECT IDENTIFIER 1.2.840.113549.1.9.5 signingTime (PKCS #9)
          SET (1 elem)
            UTCTime 2018-11-13 12:08:20 UTC
        SEQUENCE (2 elem)
          OBJECT IDENTIFIER 1.2.840.113549.1.9.4 messageDigest (PKCS #9)
          SET (1 elem)
            OCTET STRING (32 byte) 166182C25D404360359A8961F9A861F4A11567C9BC0D01BF81EC647E1CA59331
        SEQUENCE (2 elem)
          OBJECT IDENTIFIER 1.2.840.113549.1.9.77
          SET (1 elem)
            UTF8String Как дебажить ошибки.docx
        SEQUENCE (2 elem)
          OBJECT IDENTIFIER 1.3.6.1.4.1.6801.2.8
          SET (1 elem)
            SEQUENCE (10 elem)
              SET (1 elem)
              SET (1 elem)
                SEQUENCE (2 elem)
                  OBJECT IDENTIFIER 2.5.4.4 surname (X.520 DN component)
                  UTF8String ТЕСТ
              SET (1 elem)
                SEQUENCE (2 elem)
                  OBJECT IDENTIFIER 2.5.4.5 serialNumber (X.520 DN component)
                  PrintableString IIN123128350133
              SET (1 elem)
                SEQUENCE (2 elem)
                  OBJECT IDENTIFIER 2.5.4.6 countryName (X.520 DN component)
                  PrintableString KZ
              SET (1 elem)
                SEQUENCE (2 elem)
                  OBJECT IDENTIFIER 2.5.4.7 localityName (X.520 DN component)
                  UTF8String АСТАНА
              SET (1 elem)
                SEQUENCE (2 elem)
                  OBJECT IDENTIFIER 2.5.4.8 stateOrProvinceName (X.520 DN component)
                  UTF8String АСТАНА
              SET (1 elem)
                SEQUENCE (2 elem)
                  OBJECT IDENTIFIER 2.5.4.10 organizationName (X.520 DN component)
                  UTF8String ТОВАРИЩЕСТВО С ОГРАНИЧЕННОЙ ОТВЕТСТВЕННОСТЬЮ "777"
              SET (1 elem)
                SEQUENCE (2 elem)
                  OBJECT IDENTIFIER 2.5.4.11 organizationalUnitName (X.520 DN component)
                  UTF8String BIN123840007123
              SET (1 elem)
                SEQUENCE (2 elem)
                  OBJECT IDENTIFIER 2.5.4.42 givenName (X.520 DN component)
                  UTF8String ТЕСТ
              SET (1 elem)
                SEQUENCE (1 elem)
                  OBJECT IDENTIFIER 1.2.840.113549.1.9.1 emailAddress (PKCS #9. Deprecated, use an altName extension instead)
        SEQUENCE (2 elem)
          OBJECT IDENTIFIER 1.3.6.1.5.5.7.48.1.1 ocspBasic (OCSP)
          SET (1 elem)
            OCTET STRING (1 elem)
              SEQUENCE (2 elem)
                ENUMERATED
                [0] (1 elem)
                  SEQUENCE (2 elem)
                    OBJECT IDENTIFIER 1.3.6.1.5.5.7.48.1.1 ocspBasic (OCSP)
                    OCTET STRING (1 elem)
                      SEQUENCE (4 elem)
                        SEQUENCE (4 elem)
                          [1] (1 elem)
                            SEQUENCE (7 elem)
                              SET (1 elem)
                                SEQUENCE (2 elem)
                                  OBJECT IDENTIFIER 2.5.4.3 commonName (X.520 DN component)
                                  UTF8String OCSP RESPONDER
                              SET (1 elem)
                                SEQUENCE (2 elem)
                                  OBJECT IDENTIFIER 2.5.4.5 serialNumber (X.520 DN component)
                                  PrintableString IIN761231300313
                              SET (1 elem)
                                SEQUENCE (2 elem)
                                  OBJECT IDENTIFIER 2.5.4.6 countryName (X.520 DN component)
                                  PrintableString KZ
                              SET (1 elem)
                                SEQUENCE (2 elem)
                                  OBJECT IDENTIFIER 2.5.4.7 localityName (X.520 DN component)
                                  UTF8String АСТАНА
                              SET (1 elem)
                                SEQUENCE (2 elem)
                                  OBJECT IDENTIFIER 2.5.4.8 stateOrProvinceName (X.520 DN component)
                                  UTF8String АСТАНА
                              SET (1 elem)
                                SEQUENCE (2 elem)
                                  OBJECT IDENTIFIER 2.5.4.10 organizationName (X.520 DN component)
                                  UTF8String АКЦИОНЕРНОЕ ОБЩЕСТВО "НАЦИОНАЛЬНЫЕ ИНФОРМАЦИОННЫЕ ТЕХНОЛОГИИ"
                              SET (1 elem)
                                SEQUENCE (2 elem)
                                  OBJECT IDENTIFIER 2.5.4.11 organizationalUnitName (X.520 DN component)
                                  UTF8String BIN000740000728
                          GeneralizedTime 2018-11-13 12:08:12 UTC
                          SEQUENCE (1 elem)
                            SEQUENCE (3 elem)
                              SEQUENCE (4 elem)
                                SEQUENCE (2 elem)
                                  OBJECT IDENTIFIER 1.2.398.3.10.1.3.1
                                  NULL
                                OCTET STRING (32 byte) CB71EA9140B5F7D0A761D820E5FBE12C8FFB771B954165D8FC7387758D424F9A
                                OCTET STRING (32 byte) 640A1103E2579C4AFDBC3306E07AC6AA1473FA0E2E7DD005F3E6254195D828AA
                                INTEGER (159 bit) 616944972507369995033056199378545336054600461801
                              [0]
                              GeneralizedTime 2018-11-13 12:08:12 UTC
                          [1] (1 elem)
                            SEQUENCE (2 elem)
                              SEQUENCE (2 elem)
                                OBJECT IDENTIFIER 1.3.6.1.5.5.7.48.1.2 ocspNonce (OCSP)
                                OCTET STRING (1 elem)
                                  OCTET STRING ¤}Z
                              SEQUENCE (2 elem)
                                OBJECT IDENTIFIER 1.3.6.1.5.5.7.48.1.9
                                OCTET STRING (1 elem)
                                  NULL
                        SEQUENCE (2 elem)
                          OBJECT IDENTIFIER 1.2.398.3.10.1.1.1.2
                          NULL
                        BIT STRING (512 bit) 1011010110100000001011110110010101000001111111110100110110001111100011…
                        [0] (1 elem)
                          SEQUENCE (1 elem)
                            SEQUENCE (3 elem)
                              SEQUENCE (8 elem)
                                [0] (1 elem)
                                  INTEGER 2
                                INTEGER (158 bit) 272744986983533272580483628423012745646484689418
                                SEQUENCE (2 elem)
                                  OBJECT IDENTIFIER 1.2.398.3.10.1.1.1.2
                                  NULL
                                SEQUENCE (2 elem)
                                  SET (1 elem)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.4.6 countryName (X.520 DN component)
                                      PrintableString KZ
                                  SET (1 elem)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.4.3 commonName (X.520 DN component)
                                      UTF8String ҰЛТТЫҚ КУӘЛАНДЫРУШЫ ОРТАЛЫҚ (GOST)
                                SEQUENCE (2 elem)
                                  UTCTime 2018-08-11 18:00:55 UTC
                                  UTCTime 2019-08-11 18:00:55 UTC
                                SEQUENCE (7 elem)
                                  SET (1 elem)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.4.3 commonName (X.520 DN component)
                                      UTF8String OCSP RESPONDER
                                  SET (1 elem)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.4.5 serialNumber (X.520 DN component)
                                      PrintableString IIN761231300313
                                  SET (1 elem)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.4.6 countryName (X.520 DN component)
                                      PrintableString KZ
                                  SET (1 elem)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.4.7 localityName (X.520 DN component)
                                      UTF8String АСТАНА
                                  SET (1 elem)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.4.8 stateOrProvinceName (X.520 DN component)
                                      UTF8String АСТАНА
                                  SET (1 elem)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.4.10 organizationName (X.520 DN component)
                                      UTF8String АКЦИОНЕРНОЕ ОБЩЕСТВО "НАЦИОНАЛЬНЫЕ ИНФОРМАЦИОННЫЕ ТЕХНОЛОГИИ"
                                  SET (1 elem)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.4.11 organizationalUnitName (X.520 DN component)
                                      UTF8String BIN000740000728
                                SEQUENCE (2 elem)
                                  SEQUENCE (2 elem)
                                    OBJECT IDENTIFIER 1.2.398.3.10.1.1.1.1
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 1.2.398.3.10.1.1.1.1.1
                                      OBJECT IDENTIFIER 1.2.398.3.10.1.3.1.1.0
                                  BIT STRING (1 elem)
                                    OCTET STRING (64 byte) D20F80BBB987C85D946C54C3AB994F7887BDA2FE5C9C392A30AB615B407765CD8D3D78…
                                [3] (1 elem)
                                  SEQUENCE (7 elem)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.29.37 extKeyUsage (X.509 extension)
                                      OCTET STRING (1 elem)
                                        SEQUENCE (1 elem)
                                          OBJECT IDENTIFIER 1.3.6.1.5.5.7.3.9 ocspSigning (PKIX key purpose)
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.29.35 authorityKeyIdentifier (X.509 extension)
                                      OCTET STRING (1 elem)
                                        SEQUENCE (1 elem)
                                          [0] (4 byte) 5B6A73E9
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.29.14 subjectKeyIdentifier (X.509 extension)
                                      OCTET STRING (1 elem)
                                        OCTET STRING (20 byte) 042ECC160C088D0915A0F66BDD9F8205D9F56A0E
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.29.31 cRLDistributionPoints (X.509 extension)
                                      OCTET STRING (1 elem)
                                        SEQUENCE (1 elem)
                                          SEQUENCE (1 elem)
                                            [0] (1 elem)
                                              [0] (2 elem)
                                                [6] http://crl.pki.gov.kz/nca_gost.crl
                                                [6] http://crl1.pki.gov.kz/nca_gost.crl
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 2.5.29.46 freshestCRL (X.509 extension)
                                      OCTET STRING (1 elem)
                                        SEQUENCE (1 elem)
                                          SEQUENCE (1 elem)
                                            [0] (1 elem)
                                              [0] (2 elem)
                                                [6] http://crl.pki.gov.kz/nca_d_gost.crl
                                                [6] http://crl1.pki.gov.kz/nca_d_gost.crl
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 1.3.6.1.5.5.7.1.1 authorityInfoAccess (PKIX private extension)
                                      OCTET STRING (1 elem)
                                        SEQUENCE (2 elem)
                                          SEQUENCE (2 elem)
                                            OBJECT IDENTIFIER 1.3.6.1.5.5.7.48.2 caIssuers (PKIX subject/authority info access descriptor)
                                            [6] http://pki.gov.kz/cert/nca_gost.cer
                                          SEQUENCE (2 elem)
                                            OBJECT IDENTIFIER 1.3.6.1.5.5.7.48.1 ocsp (PKIX)
                                            [6] http://ocsp.pki.gov.kz
                                    SEQUENCE (2 elem)
                                      OBJECT IDENTIFIER 1.3.6.1.5.5.7.48.1.5 ocspNoCheck (OCSP)
                                      OCTET STRING (0 elem)
                              SEQUENCE (2 elem)
                                OBJECT IDENTIFIER 1.2.398.3.10.1.1.1.2
                                NULL
                              BIT STRING (512 bit) 1001000111110101000101110111000111010000111111101010101010010100110110…
问题暂未有回复.您可以查看右边的相关问题.
3 PKCS7验证错误:ASN1数据损坏

我正在开发一个以PKCS7格式签名文本文件的Java类。 我发现可以使用Sun库而不是BouncyCastle来执行此操作,因此我开发了以下方法: 当我尝试在在线验证器https://www.receita.fazenda.gov.br/Aplicacoes/SSL/ATBHE/ass ...

4 将PKCS7签名的数据附加到pdf

使用此链接iText-生成没有证书链的PDF哈希值我尝试创建具有空签名外观的pdf,还使用PdfSignature.getRangeStream()计算了哈希值。我还设法使用PdfSignature.getRangeStream()对该哈希值进行了签名。 该答案没有简要说明签名的执行方式, ...

5 向PKCS7分离签名添加内容

我有一个内容应用程序,它将PKCS7分离的签名存储在数据库中,并将原始文件存储在磁盘上。 现在,我必须将包含原始文档和签名的唯一文件发送给客户,就像附加了签名一样。 请注意,该文档尚未加密,也不会被加密。 有人知道如何以编程方式(在.Net,Java等环境中)或使用命令行工具来执行此操作吗 ...

6 pkcs7签名消息

当创建as / mime消息时,您在第二部分(第一部分是实际消息)中应该同时提供与您签名消息的证书以及签名的结果(即摘要),您应该如何将它们串联起来? 我不使用任何有弹性的城堡之类的图书馆。 我正在手工构建消息。 您只是应该将它们彼此串联在一起,还是在它们之间用新的界线连接或如何连接? ...

7 PKCS7和“ NONEwithRSA”签名

我需要使用带有sha256和RSA的未封装pkcs7计算一些数据签名。 原始内容没问题,使用: 但是,在另一个用户案例中,我没有原始内容,只有其哈希(sha256)Bouncycastle不支持“ NONEwithRSA”或“ RSA”用于pkcs7签名,因此我尝试使用自定义Conte ...

8 使用PasswordRecipientInfo从ASN1读取PKCS#7

我正在读取PKCS#15文件(asn1)。 最终,我最终得到了一个pkcs#7结构,其中包含一个PasswordRecipientInfo(PBKDF2)。 我可以将asn1结构读入Bouncy Castle EnvelopedData。 我可以手动读取所有加密参数,并且知道用于解密数 ...

9 如何将OCSP支持添加到Python请求库中?

有什么方法可以通过请求库实现OCSP检查吗? 我现在看到的唯一可行的方法是使用pyOpenSSL ,但这意味着必须与服务器建立单独的独立连接以获取证书,然后连接到颁发者以进行验证。 然后,那里有这样的实现吗? 您是否已经解决了该问题并希望进行报告? M2Crypto至少也希望 ...

10 从etoken创建PKCS7签名

我正在尝试使用etoken生成数字签名。 我正在使用BouncyCastle库,并且正在生成签名。 问题是我想要pkcs7格式的文件,它还包含'----- BEGIN PKCS7 -----'这样的标签,并以'----- END PKCS7 -----'结尾。但是签名我生成的代码不包含这些标 ...

暂无
暂无

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

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