27 #include <openssl/pem.h>
28 #include <openssl/err.h>
53 std::ifstream stream(
file.
getPath().c_str(), ios::in);
68 return getPrivateRSA();
70 return getPublicRSA();
78 EVP_PKEY* ret = EVP_PKEY_new();
79 FILE * pkey_file = fopen(
file.
getPath().c_str(),
"r");
85 ret = PEM_read_PrivateKey(pkey_file, &ret, NULL, NULL);
91 ret = PEM_read_PUBKEY(pkey_file, &ret, NULL, NULL);
104 RSA* SecurityKey::getPrivateRSA()
const
106 RSA *rsa = RSA_new();
108 FILE * rsa_pkey_file = fopen(
file.
getPath().c_str(),
"r");
109 if (!rsa_pkey_file) {
113 if (!PEM_read_RSAPrivateKey(rsa_pkey_file, &rsa, NULL, NULL)) {
115 ERR_print_errors_fp(stderr);
118 fclose(rsa_pkey_file);
122 RSA* SecurityKey::getPublicRSA()
const
124 RSA *rsa = RSA_new();
126 FILE * rsa_pkey_file = fopen(
file.
getPath().c_str(),
"r");
127 if (!rsa_pkey_file) {
131 if (!PEM_read_RSA_PUBKEY(rsa_pkey_file, &rsa, NULL, NULL)) {
133 ERR_print_errors_fp(stderr);
136 fclose(rsa_pkey_file);