openssl 获取base64编码证书

来源:互联网 发布:php微信扫码支付源码 编辑:程序博客网 时间:2024/05/10 20:17
 //方便看清过程,未加入异常考虑,商用请自行加入
string CCertTools::GetCertBase64(X509 *pCert){  BIO *bio_cert = BIO_new(BIO_s_mem());  PEM_write_bio_X509(bio_cert, pCert);  BUF_MEM *bptr = NULL;  BIO_get_mem_ptr(bio_cert, &bptr);  int iLen = bptr->length + 10;  char *buf = (char*)malloc(iLen);  memset(buf, 0, iLen);  memcpy(buf, bptr->data, bptr->length);  string str = buf;  free(buf);  buf = NULL;  BIO_free(bio_cert);  bio_cert = NULL;  return str;}
软件定制,程序代写 淘宝店铺:http://shop108027805.taobao.com
0 0
原创粉丝点击