Hi,
I am trying to load a cert from a char buffer, I am getting an error,
"error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag"


This is the code snippet, could one somene please tell me what is the error ??? 
And how do we rectify it.

Thanks,
Saleem

int SClient::loadCert(char *v_cert)
{

  try
  {
        BIO *err = NULL;
        X509 *x=NULL;
        BIO *cert = NULL;
        BIO *STDout=NULL;
        int len = -1;
        int test = 0; 
        unsigned char *buf = NULL, *p;
        char errStr[512];
        int ierr = 0;

        if ((cert = BIO_new(BIO_s_mem())) == NULL) {
                ERR_print_errors(err);

        }

        if (v_cert == NULL)
                BIO_set_fp(cert, stdin, BIO_NOCLOSE);
        else {

                if (BIO_puts(cert, v_cert) <= 0) {
                BIO_printf(err, "Unable to read %s\n", v_cert);
                 int ierr = ERR_get_error();

                  ERR_error_string(ierr, errStr);
                }
        }

        // This is returning NULL
        x = d2i_X509_bio(cert, NULL);


          ierr = ERR_get_error();

          ERR_error_string(ierr, errStr);


          m_pSSL_CTX = SSL_CTX_new(m_pSslMethod);


          // Load the certificate
          int iResult = SSL_CTX_use_certificate(m_pSSL_CTX, x);

          int ierr = ERR_get_error();

          ERR_error_string(ierr, errStr);


  }

catch( ...)
  {
        //("Unexpected exception");

        return 0;
  }

  return 1;

}



Reply via email to