Creating SSL keys, CSRs, self-signed certificates, and .pem files.

What is the whole darned process?

Well that’s a good question. For my purposes, this is what I need to know:

  1. Create a Private Key. These usually end in the file extension “key” If you already have one, don’t worry - it’s cool, we’ll be using that one.
  2. Create a Certificate Signing Request. These usually end in the extension “csr”, and are sent to the certificate authority to generate a certificate.
  3. If you’re not going to be using an existing service (usually for pay) as a certificate authority, you can create your own Certificate Authority, or self-sign your certificate.
  4. Submit your CSR to the CA and get the results. If you’re doing it yourself, I’ll tell you how. The CA creates a Certificate file, which ends in “.crt”.
  5. Take the whole collection of files, keep them somewhere safe, and mash them together to create your PEM file (this is usually just used for email.)

So. Let’s get started, eh?

Step Zero: Basic Assumptions

  • I’ll assume your domain name is domain.tld.
  • I’ll assume you have OpenSSL installed.
  • I’ll assume that you are running some form of Linux. I use Debian.

Step One: Create your Private Key

Ok, here you’re going to create your key - and treat is as such. This should be kept private, and not shared with anyone.

Now, you have a couple of options here - the first is to create your private key with a password, the other is to make it without one. If you create it with a password, you have to type it in every time your start any server that uses it.

Important: If you create your private key with a password, you can remove it later. I recommend creating your private key with a password, and then removing it temporarily every time you need to use it. When you’re done with the key without a password, delete it so it isn’t a security risk.

Create your Private key with a password

openssl genrsa -des3 -out domain.tld.encrypted.key 1024

Create your Private key without a password

openssl genrsa -out domain.tld.key 1024

If you created your private key with a password, you’ll want to complete the rest of the steps using a decrypted private key - else you’ll have to type in your password every time you use the certificate (ie: every time you start a daemon using that certificate.)

Remove the password and encryption from your private key

openssl rsa -in domain.tld.encrypted.key -out domain.tld.key

Step Two: Create a CSR

On this step you’re going to create what you actually send to your Certificate Authority. If you set a password with your Private Key, you’ll be required to enter it to create the CSR. After you finish all these steps, you can delete your CSR.

Create your Certificate Signing Request

openssl req -new -key domain.tld.key -out domain.tld.csr

Step Three: Create your Certificate

You have three options here: 1. Self-signing 2. Creating a certificate authority (CA) 3. Paying a CA to create your certificate for you.

Here’s what’s up: Self-signing is easy, free, and quick. Creating a CA isn’t terribly difficult, but probably more than you want to handle for something small. Paying for a CA can be cheap ($20), easy, quick, and comes with browser-recognition, which is generally important for public websites; especially commercial ones.

My advice: Self-sign your certificates for personal things, and pay for a certificate if its public and important.

If you’d like to pay for someone to sign your certificates, do some research and find which one you want to use. Next, find their instructions for submitting your CSR file.

Self-Sign your Certificate

openssl x509 -req -days 365 -in domain.tld.csr -signkey domain.tld.key -out
domain.tld.crt

If you do happen to want to setup your own certificate authority, check these resources out:

Step Four: Creating a PEM file

A PEM file is used by many different daemons, however how to generate such a PEM file can be hard to come by. There are some complicated ways to build one, however I have had pretty good success with simply combining the .key and the .crt file together:

cat domain.tld.key domain.tld.crt > domain.tld.pem

Disclaimer

I am not an expert with SSL, which is exactly why I created this. This may not be accurate, YMMV, etc. Be careful. Also: Your .key is private. Keep that safe, with appropriate permissions. Make sure nobody else can access it, and do not give it away to anyone. If you have any insight, feel free to comment - I would appreciate them.

原帖地址:http://grahamc.com/blog/openssl-madness-how-to-create-keys-certificate-signing-requests-authorities-and-pem-files

时间: 2025-01-05 23:22:54

Creating SSL keys, CSRs, self-signed certificates, and .pem files.的相关文章

Cross platform GUI for creating SSL certs with OpenSSL

Someone said: from : https://micksmix.wordpress.com/2012/08/09/xca-cross-platform-gui-for-creating-ssl-certs-with-openssl/ Download: http://sourceforge.net/projects/xca/ There are some of you that know your way around OpenSSL’s options in your sleep,

Nginx配置SSL安全证书避免启动输入Enter PEM pass phrase

配置好的Nginx每次启动都要输入PEM pass phrase,如何避免Nginx启动出现Enter PEM pass phrase呢? 这种情况可能是在设置私钥key时将密码设置写入了key文件,导致Nginx/Apache等系列服务器在启动时要求Enter PEM pass phrase.我们需要做的是剥离这个密码,利用如下OpenSSL命令生成server.key.unsecure文件: openssl rsa -in server.key -out server.key.unsecur

学习笔记:Creating and using a name spaced Class --FROM:Uploading Files Securely With PHP

1.name space使用方法 一般我们为每一个namespace创建一个同名的文件夹,将这个namespace之下的所有class放到这个文件夹里面: 假如我们创建一个名为:MyNamespace的namespace,和一个MyClass的类属于MyNamespace,那么首先我们要在定义MyClass的文件中写入如下代码: namespace MyNamespace; 而且这段代码之前不要插入任何其他元素. 在要使用MyNamespace的文件中,在文档开始的地方插入如下代码: use M

if the parser found inconsistent certificates on the files in the .apk.104

当静默安装提示104时,是说升级的APK 和本地已经安装的APK 签名不一致,所以无法升级. 经百度,找到知乎同学@陈子腾的回答,找到了问题所在. 可以比对apk签名的fingerprint. 假定安装了JDK,如果想查HelloWorld.apk所使用的签名的fingerprint,可以这样做: 1. 查找apk里的rsa文件 (Windows)> jar tf HelloWorld.apk |findstr RSA (Linux)$ jar tf HelloWorld.apk |grep R

larave5安装过程分享-MAX OSX版本

MAC上的平台是XAMPP,自带的版本低. 我用的是XAMPP MAC版本 一 本地php环境配置 $which php   $php-v | php xampp php  PASH=" /applications/xampp/bin/:$PASH" sudo nano vi ~/.bash_profile export PATH="/Applications/XAMPP/bin:$PATH" ctrl O 保存 ctrl X 退出 注: httpd.conf. a

安装reactnative 过程

Last login: Sun Jun  5 09:00:07 on ttys001chengchuandeMacBook-Pro:~ skycc$ brewPlease run brew update!chengchuandeMacBook-Pro:~ skycc$ brew -vHomebrew 0.9.8 (no git repository)Homebrew/homebrew-core N/AchengchuandeMacBook-Pro:~ skycc$ brew install wg

CTF内存取证

获取dump的系统版本 [email protected]:/test# volatility -f mem.dump imageinfo Volatility Foundation Volatility Framework 2.6 INFO : volatility.debug : Determining profile based on KDBG search... Suggested Profile(s) : Win7SP1x64, Win7SP0x64, Win2008R2SP0x64,

mac10.9.5 php5.4.45安装composer 简记

由于一直没升级系统版本,php也一直用的是系统默认的,导致新的一些东西用起来会有问题, 比如 composer ...  之前一直 没去理会,这次有个资源在github上没找到,想了想还必须弄弄这个东西了,废话不多说了,流水账如下: 系统版本: os x 10.9.5   php5.4.45   php配置简记 '/private/var/tmp/apache_mod_php/apache_mod_php-87.10~1/php/configure'  '--prefix=/usr'  '--m

MAC OS brew的使用

brew 是 Mac 下的一个包管理工具,类似于 centos 下的 yum,可以很方便地进行安装/卸载/更新各种软件包,例如:nodejs, elasticsearch, kibana, mysql, mongodb 等等,可以用来快速搭建各种本地环境,程序员必备工具 安装 brew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 安装