Git Product home page Git Product logo

Comments (3)

bsanchezb avatar bsanchezb commented on September 26, 2024 1

Hi,

It seems like the structure of the applied signingCertificateV2 element is not correct. In your sample, it starts from an OCTETSTRING, while it should begin with a SEQUENCE, see RFC 5035. See below an example of a valid signingCertificateV2 attribute:

SEQUENCE
  ObjectIdentifier signingCertificateV2 (1 2 840 113549 1 9 16 2 47)
  SET
    SEQUENCE
      SEQUENCE
        SEQUENCE
          OCTETSTRING d2db2 <...> b5dad
          SEQUENCE
            SEQUENCE
              [4]
                SEQUENCE
                  SET
                    SEQUENCE
                      ObjectIdentifier countryName (2 5 4 6)
                      PrintableString 'SI'
                  SET
                    SEQUENCE
                      ObjectIdentifier organizationName (2 5 4 10)
                      PrintableString 'Ha'
                  SET
                    SEQUENCE
                      ObjectIdentifier organizationIdentifier (2 5 4 97)
                      PrintableString 'VA'
                  SET
                    SEQUENCE
                      ObjectIdentifier commonName (2 5 4 3)
                      PrintableString 'TEST'
            INTEGER 33ae

Best regards,
Aleksandr

from dss-demonstrations.

IonutCorbu avatar IonutCorbu commented on September 26, 2024

Thank you! I'm still trying to solve the problem!

from dss-demonstrations.

IonutCorbu avatar IonutCorbu commented on September 26, 2024

I figured it out! The correct way to add the ess_signing_certificate is using OpenSSL is:

ESS_SIGNING_CERT_V2* signing_cert = OSSL_ESS_signing_cert_v2_new_init(EVP_get_digestbyname(this->hash_type.c_str()), this->x509_cert, this->x509_chain, -1);

int len_sign_cert = i2d_ESS_SIGNING_CERT_V2(signing_cert, NULL);

unsigned char* encoded_data = (unsigned char*)malloc(len_sign_cert * sizeof(unsigned char));

unsigned char* p = encoded_data; // i2d function is moving the pointer so we have to save the initial position
i2d_ESS_SIGNING_CERT_V2(signing_cert, &p);

ASN1_STRING* seq = ASN1_STRING_new();
ASN1_STRING_set(seq, encoded_data, len_sign_cert);
PKCS7_add_signed_attribute(p7Si, NID_id_smime_aa_signingCertificateV2, V_ASN1_SEQUENCE, seq);

This is a slice of code, some attributes are initialized as members of a class.
I hope this would help other people who will have the same issue!

from dss-demonstrations.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.