1.等同于使用: openssl req -new -key "key_path" -out "save_path" -subj "/emailAddress=email/CN=name/C=country"
2.代码如下:keyFilePath为RSA private key 文件。
bool MakeCsrSSL(const char * keyFilePath, const char *email, const char *name, const char *country, const char *saveCsrFilePath) {
int ret = 0;
RSA *r = NULL;
BIGNUM *bne = NULL;
int nVersion = 1;
int bits = 2048;
unsigned long e = RSA_F4;
X509_REQ *x509_req = NULL;
X509_NAME *x509_name = NULL;
EVP_PKEY *pKey = NULL;
RSA *tem = NULL;
BIO *out = NULL, *keyFileBIO = NULL;
FILE *pubKeyFile = NULL;
if (strlen(saveCsrFilePath) == 0) {
fprintf(stderr, "MakeLocalCsrSSLApi save path is empty\n");
return false;
}
//not exists public key file, create one immediately.