error code -207 during import of certificate using GnuTLS

507 views Asked by At

I try to import a certificate, to process it in my C++ code. What am I doing wrong? Here are the steps I perform in my code:

I initiate with gnutls_global_init()

I get a FILE-type opject into my programm, using fopen and fread

I save the FILE-type obejct containing the certificate and the length of the FILE-type into a gnutls_datum_t-type object (loaded_file)

I init a gnutls certificate with gnutls_x509_crt_init(&cert)

I use gnutls_x509_crt_import(cert, &loaded_file, GNUTLS_X509_FMT_PEM)

I get the error code -207: Base64 unexpected header error...what does this mean? when I want to print the certificate information using gnutls_x509_crt_print() I get the following information:

cert[1424]:

X.509 Certificate Information:

Version: 1

error: get_serial: ASN1 parser: Value was not found.

Issuer:

Validity:

   Not Before: Wed Dec 31 23:59:59 UTC 1969
    Not After: Wed Dec 31 23:59:59 UTC 1969

Subject:

error: get_signature_algorithm: ASN1 parser: Value was not found.

warning: signed using a broken signature algorithm that can be forged.

error: get_signature: ASN1 parser: Value was not found.

Other Information:

error: get_fingerprint: ASN1 parser: Value was not found.

error: get_key_id: ASN1 parser: Value was not found.


The certificate I am trying to import is a selfsigned certificate created with certtool.

what is wrong in my import-chain?

1

There are 1 answers

0
David Gausmann On BEST ANSWER

Today I got the same error code. In my case I used the wrong buffer and tried to load the private key instead of the certificate using gnutls_x509_crt_import. It seems that the error code -207 is generic for "I didn't find any license".

So if this error occurs, you should always check the input buffer for correct data.