diff options
Diffstat (limited to 'src/apps/pkcs10.cpp')
-rw-r--r-- | src/apps/pkcs10.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/apps/pkcs10.cpp b/src/apps/pkcs10.cpp new file mode 100644 index 000000000..6e36f73fb --- /dev/null +++ b/src/apps/pkcs10.cpp @@ -0,0 +1,48 @@ +#include "apps.h" +#include <botan/x509self.h> +#include <botan/rsa.h> +#include <botan/dsa.h> +using namespace Botan; + +#include <iostream> +#include <fstream> +#include <memory> + +int pkcs10(int argc, char* argv[]) + { + if(argc != 6) + { + std::cout << "Usage: " << argv[0] + << " passphrase name country_code organization email" << std::endl; + return 1; + } + + try + { + AutoSeeded_RNG rng; + + RSA_PrivateKey priv_key(rng, 1024); + + std::ofstream key_file("private.pem"); + key_file << PKCS8::PEM_encode(priv_key, rng, argv[1]); + + X509_Cert_Options opts; + + opts.common_name = argv[2]; + opts.country = argv[3]; + opts.organization = argv[4]; + opts.email = argv[5]; + + PKCS10_Request req = X509::create_cert_req(opts, priv_key, + "SHA-256", rng); + + std::ofstream req_file("req.pem"); + req_file << req.PEM_encode(); + } + catch(std::exception& e) + { + std::cout << e.what() << std::endl; + return 1; + } + return 0; + } |