Skip to content

Instantly share code, notes, and snippets.

@emmiep
Created November 4, 2019 18:31
Show Gist options
  • Select an option

  • Save emmiep/d97c703e89f82a85eada3c7c97a0e7f2 to your computer and use it in GitHub Desktop.

Select an option

Save emmiep/d97c703e89f82a85eada3c7c97a0e7f2 to your computer and use it in GitHub Desktop.
Read private RSA key from PEM file
#include <stdio.h>
#include <openssl/pem.h>
#include <openssl/rsa.h>
int main(int argc, char *argv[]) {
FILE *f = fopen(argv[1], "r");
RSA *key = PEM_read_RSAPrivateKey(f, NULL, NULL, NULL);
RSA_print_fp(stdout, key, 0);
fclose(f);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment