Hi Tim, I think the problem is that you are casting a BSTR to a char*, you need to use a conversion routine, e.g. something like:
void somefunc(BSTR bstrText) { _bstr_t _bstrText(bstrText, false); char* lpszText = (char*)_bstrText; .. Cheers, Mark ----- Original Message ----- From: "Tim Coleman" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, September 19, 2002 2:48 PM Subject: Creating a COM object to use openssl > Hi, > > I've been working on making a COM object that uses OpenSSL to sign some > data that I'm using for a form of software licensing. I have code that > works fine as an executable on Windows, but when I try to make a COM > object, I can't seem to load the private key from a string. I'm not > sure if I'm doing something wrong or not. > > Here's the code I have to load the private RSA key from a string. After > this has been run, key is NULL, so it didn't succeed in loading the key > from the given string. > > STDMETHODIMP CLicence::GenerateLicence(BSTR licenceData, BSTR keyString, > BSTR passphrase, BSTR *licence) > { > AFX_MANAGE_STATE(AfxGetStaticModuleState()) > EVP_MD *md = EVP_sha1(); > EVP_add_cipher( EVP_des_ede3_cbc() ); > > EVP_PKEY *key = NULL; > BIO *bio = BIO_new_mem_buf( (char *) keyString, -1 ); > PEM_read_bio_PrivateKey(bio, &key, NULL, (char *) passphrase ); > BIO_free( bio ); > ... > > I'm trying to access this object from an ASP page. The specific error > from openssl is "error:0906D06C:PEM routines:PEM_read_bio:no start line" > > Does anyone have any ideas on what might cause this? > > Thanks, > > -- > Tim Coleman <[EMAIL PROTECTED]> > Web Developer, Open Text Corporation Global Services > Tel: 519 888 7111 ext. 2619 > Fax: 519 888 6737 > > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List [EMAIL PROTECTED] > Automated List Manager [EMAIL PROTECTED] > ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]