pem

How to create .pem files for https web server

瘦欲@ 提交于 2019-11-27 05:48:34
I'm using the Express framework in Node.js to create a web server. I want the transport is based on SSL. The code to create the https web server is as below. var app = express.createServer({ key: fs.readFileSync('./conf/key.pem'), cert: fs.readFileSync('./conf/cert.pem') }); module.exports = app; Question: How to create the key.pem and cert.pem required by express? The two files you need are a PEM encoded SSL certificate and private key. PEM encoded certs and keys are Base64 encoded text with start/end delimiters that look like -----BEGIN RSA PRIVATE KEY----- or similar. To create an SSL

Correctly create RSACryptoServiceProvider from public key

﹥>﹥吖頭↗ 提交于 2019-11-27 05:20:25
I'm currently trying to create an RSACryptoServiceProvider object solely from a decoded PEM file. After several days of searching, I did manage to wrangle a working solution but it's not one that would be production ready. In a nutshell, in order to create an RSACryptoServiceProvider object from the bytes that make up the public key in a PEM file, I must create the object specifying the keysize (currently 2048 using SHA256, specifically) and then importing a RSAParameters object with the Exponent and Modulus set. I'm doing this as so; byte[] publicKeyBytes = Convert.FromBase64String

Using a PEM encoded, encrypted private key to sign a message natively

落花浮王杯 提交于 2019-11-27 04:16:35
I'm trying to use a PEM(X.509) certificate (stored in a privateKey.pem file on disk) to sign messages sent via sockets in Java, but am having a lot of trouble finding an example that's close. I'm normally a C++ guy who's just stepping in to help on this project, so it's been a little difficult for me to put it all together into code that works when I'm unfamiliar with the APIs. Unfortunately, I'm limited to methods that come standard with Java (1.6.0 Update 16), so although I found a similar example using BouncyCastle 's PEMReader , it hasn't helped much on this particular project. My

scp (secure copy) to ec2 instance without password

谁都会走 提交于 2019-11-26 23:44:48
问题 I have an EC2 instance running (FreeBSD 9 AMI ami-8cce3fe5), and I can ssh into it using my amazon-created key file without password prompt, no problem. However, when I want to copy a file to the instance using scp I am asked to enter a password: scp somefile.txt -i mykey.pem root@my.ec2.id.amazonaws.com:/ Password: Any ideas why this is happening/how it can be prevented? 回答1: I figured it out. I had the arguments in the wrong order. This works: scp -i mykey.pem somefile.txt root@my.ec2.id

convert certificate from pem into jks

十年热恋 提交于 2019-11-26 23:09:12
问题 I have to convert a certificate in pem format into an java key store. To use this one with tomcat at a windows server I've got those files: cert_request.csr -----BEGIN CERTIFICATE REQUEST----- ... -----END CERTIFICATE REQUEST----- cert_public_key.pem -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE----- cert_private_key.pem -----BEGIN ENCRYPTED PRIVATE KEY----- ... -----END ENCRYPTED PRIVATE KEY----- cert.txt contains an 16 digit key I tryed to combine the pem files (by combining the two

Load an PEM encoded X.509 certificate into Windows CryptoAPI

不羁的心 提交于 2019-11-26 22:42:11
问题 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

OpenSSL's rsautl cannot load public key created with PEM_write_RSAPublicKey

∥☆過路亽.° 提交于 2019-11-26 21:46:57
问题 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 =

how to get private key from PEM file?

折月煮酒 提交于 2019-11-26 19:53:36
i have a .PEM file that includes public key and a private key for SSL data transfer like this: -----BEGIN RSA PRIVATE KEY----- private key data -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- public key data -----END CERTIFICATE----- when i want to load the .PEM file by the following code: X509Certificate2 xx = new X509Certificate2("c:\\myKey.pem"); i get an exception that says: "Cannot find the requested object." , with full stack: System.Security.Cryptography.CryptographicException was unhandled Message=Cannot find the requested object. Source=mscorlib StackTrace: at System

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

白昼怎懂夜的黑 提交于 2019-11-26 17:56:56
问题 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. 回答1: There are a couple ways to do this. First, instead of going into openssl command prompt

Node.js https pem error: routines:PEM_read_bio:no start line

萝らか妹 提交于 2019-11-26 17:26:12
I am messing with login form right now with node.js, I tried creating a pem key and csr using openssl req -newkey rsa:2048 -new -nodes -keyout key.pem -out csr.pem However I been getting errors for running node server.js Here is my server.js var http = require('http'), express = require('express'), UserServer = require('./lib/user-server'); var https = require('https'); var fs = require('fs'); var options = { key: fs.readFileSync('./key.pem', 'utf8'), cert: fs.readFileSync('./csr.pem', 'utf8') }; var app = express(); app.configure(function(){ app.use(express.bodyParser()); app.use(app.router);