如何通过openssl 将公钥 添加到证书中

RT
我现在有一段RSA秘钥,如何通过openssl 添加到我的数字证书中呢?
另外如何才能从这个证书中提取这个证书呢?

不知道你这个问题是否已经解决, 如果还没有解决的话:
  • 这篇文章:升级了OpenSSL后仍被扫描报存在漏洞的解决方案 也许能够解决你的问题,你可以看下
  • 除此之外, 这篇博客: 【openssl】使用openssl库进行base64加解密,aes解密,rsa验证签名中的 2.2 加密解密代码 部分也许能够解决你的问题, 你可以仔细阅读以下内容或者直接跳转源博客中阅读:
    //加密
    char * Base64Encode(const char * input, int length, bool with_new_line)
    {
        if(!input || !length)
            return NULL;
    	BIO * bmem = NULL;
    	BIO * b64 = NULL;
    	BUF_MEM * bptr = NULL;
    	b64 = BIO_new(BIO_f_base64());
    	if(!with_new_line) {
    		BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
    	}
    	bmem = BIO_new(BIO_s_mem());
    	b64 = BIO_push(b64, bmem);
    	BIO_write(b64, input, length);
    	BIO_flush(b64);
    	BIO_get_mem_ptr(b64, &bptr);
     
    	char * buff = (char *)malloc(bptr->length + 1);
    	memcpy(buff, bptr->data, bptr->length);
    	buff[bptr->length] = '\0';
    	BIO_free_all(b64);
     
    	return buff;
    }
    
    //解码
    char* Base64Decode(const char* input, int length, bool with_new_line)
    {
        if(!input || !length)
            return NULL;
    	BIO * b64 = NULL;
    	BIO * bmem = NULL;
    	char * buffer = (char *)malloc(length);
    	memset(buffer, 0, length);
     
    	b64 = BIO_new(BIO_f_base64());
    	if(!with_new_line) {
    		BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
    	}
    	bmem = BIO_new_mem_buf(input, length);
    	bmem = BIO_push(b64, bmem);
    	unsigned int size = BIO_read(bmem, buffer, length);
        buffer[size] = '\0';
    	BIO_free_all(bmem);
    	//调试时建议这里加log,看看你的输入输出分别是什么 
    	return buffer;
    }
    

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^