book
  • README
  • cheatsheet
    • bash
      • builtin
      • syntactic sugar
      • cmd
      • havefun
    • text-processing
      • awk
      • sed
      • html
      • json
      • regex
      • unicode
    • osx
    • curl
    • tricky
    • widget
    • proxy
    • colors
    • math
    • media
    • ssl
      • keystore
      • verification
      • server
      • client
      • tricky
    • windows
      • powershell
      • choco
      • wsl
      • wt
      • shortcut
      • clsid
      • env
      • shell:folder
  • vim
    • nvim
    • install
    • color
    • plugins
      • usage
      • other plugins
      • deprecated
    • tricky
    • viml
    • windows
    • troubleshooting
  • devops
    • admin tools
    • ssh
    • git
      • config
      • alias
      • submodule
      • eol
      • example
      • gerrit
        • gerrit API
      • github
      • troubleshooting
      • tricky
      • statistics
    • pre-commit
    • release-tools
    • tmux
      • cheatsheet
    • ansible
    • vault
    • artifactory
      • api
      • cli
      • aql
      • nginx cert
    • klocwork
      • kwadmin
      • kwserver
      • api
      • q&a
    • elk
    • mongodb
    • android
    • mobile
  • jenkins
    • config
      • windows
    • appearance
    • troubleshooting
    • jenkinsfile
      • utility
      • parallel
      • build
      • envvar
      • properties
      • trigger
      • node
    • script
      • job
      • build
      • stage
      • agent
      • security & authorization
      • exception
      • monitor
      • tricky
    • api
      • blueocean
    • cli
    • plugins
      • kubernetes
      • docker
      • shared-libs
      • lockable-resource
      • ansicolor
      • badge
      • groovy-postbuild
      • simple-theme
      • customizable-header
      • artifactory
      • jira-steps
      • job-dsl
      • build-timeline
      • crumbIssuer
      • coverage
      • uno-choice
      • tricky
  • virtualization
    • kubernetes
      • init
        • kubespray
        • kubeadm
          • environment
          • crio v1.30.4
          • docker v1.15.3
          • HA
        • addons
        • etcd
      • kubectl
        • pod
        • deploy
        • replicasets
        • namespace
        • secrets
      • node
      • certificates
      • events
      • kubeconfig
      • kubelet
      • troubleshooting
      • cheatsheet
      • auth
      • api
      • tools
        • monitor
        • helm
        • network
        • minikube
    • docker
      • run & exec
      • voume
      • remove
      • show info
      • dockerfile
      • dockerd
      • tricky
      • troubleshooting
      • windows
    • crio
    • podman
  • ai
    • prompt
  • osx
    • apps
      • init
      • brew
    • defaults
    • system
    • network
    • script
    • tricky
  • linux
    • devenv
    • util
      • time & date
      • output formatting
      • params
      • tricky
    • nutshell
    • disk
    • network
    • troubleshooting
    • system
      • apt/yum/snap
      • authorization
      • apps
      • x11
    • ubuntu
      • systemctl
      • x
    • rpi
  • programming
    • groovy
    • python
      • config
      • basic
      • list
      • pip
      • q&a
    • others
    • archive
      • angular
      • maven
      • mysql
        • installation
        • logs
      • ruby
        • rubyInstallationQ&A
  • tools
    • fonts
    • html & css
    • Jira & Confluence
    • node & npm
      • gitbook
      • hexo
      • github.page
      • code themes
    • app
      • microsoft office
      • vscode
      • virtualbox
      • iterm2
      • browser
      • skype
      • teamviewer
      • others
  • quotes
  • english
Powered by GitBook
On this page
  • terminology
  • extensions
  • algorithms
  • certs
  • generate csr
  • sign the csr
  • nginx configure
  • usage
  • show content
  • convert
  • Code Signing Certificates

Was this helpful?

  1. cheatsheet
  2. ssl

server

PreviousverificationNextclient

Last updated 11 months ago

Was this helpful?

[!TIP|label:references:]

terminology

extensions

[!TIP|label:references:]

EXTENSION
NAME
DESCRIPTION

.ca

Certificate Authority

-

.key

Private Key

-

.csr .req .p10

Certificate Signing Request

-

.crt

Certificate

.cer

Certificate

alternate form of .crt (Microsoft Convention), DER encoded or base64[PEM] encoded

.pem

indicates a base64 encoding with header and footer lines

.crl

Certificate Revocation List

.p8 .pkcs8

PKCS#8 Private Keys

PKCS#8 defines a way to encrypt private keys using

.p12 .pfx

commonly password protected. It can contain trusted certificates, private key(s) and their certificate chain(s)

.p7b .p7c

it is often used as a way to handle the certificates which make up a 'chain' or 'bundle' as a single

jks

Java Key Store

Java Key Store (JKS) is a repository of security certificates, either authorization certificates or public key certificates, plus corresponding private keys, used for instance in SSL encryption.

symmetric encryption

  • 3DES

  • AES

asymmetric encryption

  • RSA

  • DSA

  • ECC

  • ECDSA

  • Hash Algorithms

  • MD5

  • SHA-1

  • SHA-2

  • SHA-3

certs

generate csr

[!NOTE|label:references:]

# generate key
$ openssl genrsa -out dashboard.key 2048

# generate csr
$ openssl req -sha256 \
              -new \
              -key dashboard.key \
              -out dashboard.csr \
              -subj '/C=US/ST=California/L=Santa Clara/O=Company Name, Inc./CN=dashboard.kubernetes.com'
  • or generate key and csr in one command

    $ openssl req -new -newkey rsa:2048 -nodes -keyout dashboard.key -out dashboard.csr -subj '/C=US/ST=California/L=Santa Clara/O=Company Name, Inc./CN=dashboard.kubernetes.com'

sign the csr

[!TIP|label:references:]

$ echo subjectAltName = DNS: server.sample.com,IP: 10.110.136.104 >> extfile.cnf
$ echo extendedKeyUsage = serverAuth >> extfile.cnf
$ openssl x509 -req \
               -days 365 \
               -sha256 \
               -CAcreateserial \
               -CA ca.crt \                            # the CA crt
               -CAkey ca.key \                         # the CA key
               -in server.csr \
               -out server.crt \
               -extfile extfile.cnf                    # the external file
  • $ openssl x509 -req -in req.pem -extfile openssl.cnf -extensions v3_usr \
              -CA cacert.pem -CAkey key.pem -CAcreateserial
    
    # Set a certificate to be trusted for SSL client use and change set its alias to "Steve's Class 1 CA"
    $ openssl x509 -in cert.pem            -addtrust clientAuth -setalias "Steve's Class 1 CA" -out trust.pem
    # or
    $ openssl x509 -in steve.cer -trustout -addtrust clientAuth -setalias "Steve's Class 1 CA" -out steve.pem
  • $ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout nginx-selfsigned.key -out nginx-selfsigned.crt

nginx configure

[!NOTE|label:references:]

  • modify/create nginx configure

    $ cat /etc/nginx/sites-enabled/server.sample.com
    server {
        listen 80;
        listen 443 ssl;
    
        ssl_certificate     /etc/nginx/certs/server.pem;
        ssl_certificate_key /etc/nginx/certs/server.key;
        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_ciphers         HIGH:!aNULL:!MD5;
    
        server_name server.sample.com;
    
        location / {
            proxy_pass http://localhost:8080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }
    }
  • test and reload

    $ nginx -t
    $ nginx -s reload
    $ sudo systemctl restart nginx.service
    
    # more
    $ which -a nginx
    /usr/sbin/nginx
    /sbin/nginx

usage

show content

  • certificate request ( csr )

    # show content of a certificate request
    #    csr: request
    #          v
    $ openssl req -in certificate.csr -noout -text
    
    # subject name
    $ openssl req -in certificate.csr -noout -subject
    
    # verify
    $ openssl req -in certificate.csr -noout -verify
  • certificate ( pem, crt, cer )

    # show content of a certificate
    #    x509: certificate
    #          v
    $ openssl x509 -in certificate.pem -noout -text
    
    # show serial number of a certificate
    $ openssl x509 -in certificate.pem -noout -serial
    
    # show subject name
    $ openssl x509 -in certificate.pem -noout -subject
    
    # show subject name in RFC2253 format
    $ openssl x509 -in certificate.pem -noout -subject -nameopt RFC2253
    
    # show subject name in oneline support UTF8
    $ openssl x509 -in certificate.pem -noout -subject -nameopt oneline,-esc_msb
    
    # show SHA-1 fingerprint
    $ openssl x509 -sha1 -in certificate.pem -noout -fingerprint

convert

[!NOTE|label:references:]

frmo cer

  • to crt

    # DER encoded ( binary )
    $ openssl x509 -inform DER -in certificate.cer -out certificate.crt
    
    # PEM encoded ( human readable )
    $ openssl x509 -inform PEM -in certificate.cer -out certificate.crt
  • to pem

    $ openssl x509 -inform DER -in certificate.cer -out certificate.pem -outform PEM
    $ openssl x509 -inform PEM -in certificate.cer -out certificate.pem -outform PEM

from a pkcs#12 ( .pfx/.p12 )

[!NOTE|label:references:]

  • to pem

    $ openssl pkcs12 -in certificate.pfx -out certificate.pem -nodes
    
    ## -nocerts
    $ openssl pkcs12 -in filename.pfx -nocerts -out key.pem
    $ openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt -certfile CACert.crt
    
    ## -clcerts
    $ openssl pkcs12 -in filename.pfx -clcerts -nokeys -out certificate.pem

from crt

[!NOTE|label:references:]

  • to pem

    ## PEM encoded
    $ openssl x509 -in certificate.crt -out certificate.pem -outform PEM
    
    ## DER encoded
    $ openssl x509 -in certificate.crt -out certificate.der -outform DER
    
    ## from DER encoded to PEM encoded
    $ openssl x509 -in certificate.der -inform DER -out output.pem -outform PEM
$ openssl rsa -in key.pem -out key.pem

from certificate

  • to certificate request

    $ openssl x509 -x509toreq -in certificate.crt -out certificate.csr -signkey privateKey.key
    # or
    $ openssl x509 -x509toreq -in certificate.pem -out req.pem -signkey key.pem

convert from windows certmgr.msc

  1. win + r -> certmgr.msc

  2. Certifacts - Current User -> Trusted Root Certification Authorities -> Certificates -> the wanted CA

  3. right-click -> open or double-click

  4. Details -> Copy to File...

  5. Certificate Export Wizard -> Next

  6. convert to crt

  • DER encoded binary X.509 (.CER)

    $ openssl x509 -inform DER -in certificate.cer -out certificate.crt
  • Base-64 encoded X.509 (.CER)

    $ openssl x509 -inform PEM -in certificate.cer -out certificate.crt
  • Cryptographic Message Syntax Standard - PKCS #7 Certificates (.P7B)

    [!NOTE|label:references:]

    $ openssl pkcs7 -inform DER -in certificate.p7b -out certificate.crt
    # or
    $ openssl pkcs7 -print_certs -in certificate.p7b -out certificate.crt

[!NOTE|label:references:]

$ sudo cp certificate.crt /usr/local/share/ca-certificates/
$ sudo chmod 755 /usr/local/share/ca-certificates/certificate.crt
$ sudo update-ca-certificates

|

used for certificates, may be encoded as binary DER or as ASCII PEM, usually an certificate

defined within the certificate specifications, and this is usually DER encoded

defined key store

message

* iMarslo: Artifactory Nginx CSR
Frequently used OpenSSL Commands
The Most Common OpenSSL Commands
OpenSSL Commands
What is the difference between .CER and .CRT?
What are the differences between .pem, .csr, .key, .crt and other such file extensions?
Difference between pem, crt, key files
algorithms
How to generate a private key and CSR from the command line
How to Generate a CSR for Nginx (OpenSSL)
GENERATE A CERTIFICATE SIGNING REQUEST (CSR) USING OPENSSL ON MICROSOFT WINDOWS SYSTEM
HOW TO GENERATE A CSR FOR SSL CERTIFICATES ON WINDOWS
How do you sign a Certificate Signing Request with your Certification Authority?
openssl.cnf
Sign a certificate request using the CA certificate above and add user certificate extensions
or generate crt with key in one command
Configuring HTTPS servers
How to Redirect HTTP to HTTPS in Nginx
Module ngx_http_ssl_module
Update: Using Free Let’s Encrypt SSL/TLS Certificates with NGINX
Do I need to convert .CER to .CRT for Apache SSL certificates? If so, how?
x509 options
Convert pfx file to pem file
Conversion of crt file to pem file
remove password from extacted private key
jmervine/cert_convert.sh
import to Linux
Install a PEM-format certificate
Code Signing Certificates
terminology
extensions
algorithms
symmetric encryption
asymmetric encryption
certs
generate csr
sign the csr
nginx configure
usage
show content
convert
frmo cer
from a pkcs#12 ( .pfx/.p12 )
from crt
remove password from extacted private key
from certificate
convert from windows certmgr.msc
Code Signing Certificates
X509v3
Privacy Enhanced Mail
X.509v3
PKCS#12
PKCS#7/CMS
certmgr-1
certmgr-2
certmgr-3