pem

Use PEM Encoded CA Cert on filesystem directly for HTTPS request?

非 Y 不嫁゛ 提交于 2019-11-28 00:35:25
This is similar to Import PEM into Java Key Store . But the question's answers use OpenSSL for conversions and tools to import them into key stores on the file system. I'm trying to use a well formed X509 certificate as a trust anchor: static String CA_FILE = "ca-rsa-cert.pem"; public static void main(String[] args) throws Exception { KeyStore ks = KeyStore.getInstance("JKS"); ks.load(new FileInputStream(CA_FILE), null); TrustManagerFactory tmf = TrustManagerFactory .getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmf.init(ks); SSLContext context = SSLContext.getInstance("TLS");

OpenSSL's rsautl cannot load public key created with PEM_write_RSAPublicKey

人盡茶涼 提交于 2019-11-28 00:32:05
I've generated a public key using openssl BIGNUM* e = BN_new(); BN_set_word(e, 17); RSA* rsa = RSA_new(); if(!RSA_generate_key_ex(rsa, 2048, e, NULL)) { LOG(security, debug) << "failed to generate private key"; } And these are written to files: FILE* pubwriter = fopen("key.pub", "wb"); int err = PEM_write_RSAPublicKey(pubwriter, key); if(!err) { throw new std::runtime_error("Failed to store public key"); } FILE* privwriter = fopen("key.priv", "wb"); std::string password = "password"; err = PEM_write_RSAPrivateKey(privwriter, key, EVP_des_ede3_cbc(), (unsigned char*)password.c_str(), password

How to get PEM encoded X509 certificate as C++ string using openssl?

非 Y 不嫁゛ 提交于 2019-11-28 00:30:55
I have a openssl X509 structure with a self signed certificate. I need to get a PEM formatted C++ string from this structure. What are the openssl APIs that I need to use to achieve this? I tried following the example program at https://www.codeblog.org/gonzui/markup/openssl-0.9.8a/demos/x509/mkcert.c . This program shows a way to write the certificate in PEM format to a file. I can read the contents of this file into a C++ string if there is no other way to do it. look at the source of the openssl x509 command and see how it does the operation to read a DER encoded file and writes a PEM one -

How can I decode a SSL certificate using python?

北城以北 提交于 2019-11-27 19:23:14
How can I decode a pem-encoded (base64) certificate with Python? For example this here from github.com: -----BEGIN CERTIFICATE----- MIIHKjCCBhKgAwIBAgIQDnd2il0H8OV5WcoqnVCCtTANBgkqhkiG9w0BAQUFADBp MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3 d3cuZGlnaWNlcnQuY29tMSgwJgYDVQQDEx9EaWdpQ2VydCBIaWdoIEFzc3VyYW5j ZSBFViBDQS0xMB4XDTExMDUyNzAwMDAwMFoXDTEzMDcyOTEyMDAwMFowgcoxHTAb BgNVBA8MFFByaXZhdGUgT3JnYW5pemF0aW9uMRMwEQYLKwYBBAGCNzwCAQMTAlVT MRswGQYLKwYBBAGCNzwCAQITCkNhbGlmb3JuaWExETAPBgNVBAUTCEMzMjY4MTAy MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2Fu

Load an PEM encoded X.509 certificate into Windows CryptoAPI

廉价感情. 提交于 2019-11-27 18:37:12
I need to load a PEM encoded X.509 certificate into a Windows Crypto API context to use with C++. They are the ones that have -----BEGIN RSA XXX KEY----- and -----END RSA XXX KEY----- . I found examples for Python and .NET but they use specific functions I can't relate to the plain Windows Crypto API. I understand how to encrypt/decrypt once I've got a HCRYPTKEY. BUT, I just don't get how to import the Base64 blob in the .PEM file(s) and get a HCRYPTKEY that I can use out of it. I have that strange feeling that there is more to it than simply calling CryptDecodeObject() . Any pointers that can

PuTTYgen doesn't give me the option for SSH-2 RSA

一个人想着一个人 提交于 2019-11-27 17:10:38
问题 I've been accessing my AWS EC2 instance from Ubuntu for years with no issues. I'd like to also connect to it from a Windows machine. The procedure seems straight forward... copy my *.pem file to the Windows machine and convert to *.ppk using PuTTYgen. The Amazon instructions provide the following... But when I open PuTTYgen, I get... No option is available for SSH-2 RSA. What am I missing here? How do I create a .ppk in SSH-2 RSA format, when there isn't a given option? 回答1: Just skip the

How to load a public RSA key into Python-RSA from a file?

为君一笑 提交于 2019-11-27 16:28:09
问题 I generated a private and a public key using OpenSSL with the following commands: openssl genrsa -out private_key.pem 512 openssl rsa -in private_key.pem -pubout -out public_key.pem I then tried to load them with a python script using Python-RSA: import os import rsa with open('private_key.pem') as privatefile: keydata = privatefile.read() privkey = rsa.PrivateKey.load_pkcs1(keydata,'PEM') with open('public_key.pem') as publicfile: pkeydata = publicfile.read() pubkey = rsa.PublicKey.load

Reading and writing rsa keys to a pem file in C

邮差的信 提交于 2019-11-27 12:52:11
I am writing a C program to generate keys for RSA and write them to a file and then read from them. The homework requires me to generate the files in a openssl format. So, I chose PEM. Now, I have the following function for creating the file rsa = RSA_new(); // These 3 keys are generated beforehand rsa->e = e; rsa->n = n; rsa->d = d; fp = fopen(pubkey_file, "w"); if(!PEM_write_RSAPublicKey(fp, rsa)) { printf("\n%s\n", "Error writing public key"); } fflush(fp); fclose(fp); fp = fopen(privkey_file, "w"); // pRsaKey = EVP_PKEY_new(); // EVP_PKEY_assign_RSA(pRsaKey, rsa); if(!PEM_write

How can I get SecKeyRef from DER/PEM file

蹲街弑〆低调 提交于 2019-11-27 10:58:09
I need to integrate my iPhone app with a system, and they require to encrypt data by a given public key, there are 3 files in 3 different format .xml .der and .pem, I have researched and found some articles about getting SecKeyRef from DER/PEM, but they are always return nil. Below is my code: NSString *pkFilePath = [[NSBundle mainBundle] pathForResource:@"PKFile" ofType:@"der"]; NSData *pkData = [NSData dataWithContentsOfFile:pkFilePath]; SecCertificateRef cert; cert = SecCertificateCreateWithData(NULL, (CFDataRef) pkData); assert(cert != NULL); OSStatus err; if (cert != NULL) { err =

How to save public key from a certificate in .pem format

↘锁芯ラ 提交于 2019-11-27 10:31:41
I am using the below openssl command for storing my public key into a .pem file. openssl> x509 -in E:/mycert.pem -pubkey -out E:/mypubkey.pem But when i try to use this command, it is storing the whole certificate info in the mypubkey.pem file. I have seen that i can save my public key using openssl> x509 -pubkey -noout -in cert.pem > pubkey.pem But it is throwing an error. I can't use ">" operator. There are a couple ways to do this. First, instead of going into openssl command prompt mode, just enter everything on one command line from the Windows prompt: E:\> openssl x509 -pubkey -noout -in