hi,
I am having a problem when reading a certificate and
private key from a memory buffer instead of a file.
i am using d2i_X509(NULL,&cert,strlen(cert)) to read
the certificate string which was defined in one of
.pem
file. Should i use SSL_CTX_use_certificate_ASN1
instead??? Please help me.....
copied from server.pem file
unsigned char * cert
="MIIDDzCCAs2gAwIBAgICA............Qw==";
unsigned char * key =
"y5qH6Q0Nvb5SUcJEYY...........p6==";
here is my sample server code :
void ssl_server ()
{
SSL_CTX* ctx;
SSL* ssl;
X509* client_cert,*x509_cert,*x509_key;
char* str;
SSL_METHOD *meth;
int theFd;
fd_set theFdSet;
/* SSL preliminaries. We keep the certificate and
key with the context. */
SSL_load_error_strings();
SSLeay_add_ssl_algorithms();
meth = SSLv23_server_method();
ctx = SSL_CTX_new (meth);
x509_cert = d2i_X509(NULL,&cert,strlen(cert));
if (SSL_CTX_use_certificate(ctx,x509_cert) <= 0) {
return;
}
x509_key = d2i_X509(NULL,&key,sizeof(key));
if (SSL_CTX_use_PrivateKey(ctx,x509_key) <= 0) {
return;
}
if (!SSL_CTX_check_private_key(ctx)) {
printf("Private key does not match the certificate
public key\n");
return;
}
.
.
}
when d2i_X509 its failing for the following reason.
IMPLEMENT_ASN1_FUNCTIONS(X509)
ASN1_VALUE *ASN1_item_d2i(..)
asn1_check_tlen(..)
ASN1err(ASN1_F_ASN1_CHECK_TLEN, ASN1_R_WRONG_TAG);
return 0;
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]