Commands
  • About
  • Software Development
    • Glossary
    • System Design
      • CAP Theorem
      • Data Migration
      • EAV Model
      • ETL Process
      • Event Sourcing
      • Outbox Pattern
      • SOLID Principles
    • Standards
      • Character Encoding
      • Twirp
    • Elixir
      • IEx
      • Mix
      • Libraries
      • Code Snippets
    • Node.js
      • TypeScript
  • Commands
    • Bookmarks
    • AWS
      • Athena
      • ECS
    • Docker
      • Manage Images
      • Manage Containers
    • File System
      • Grep
      • Search Files
      • Miscellaneous
    • Git
      • Setup New Project
      • Manage Remotes
      • Release Project
    • GPG
    • Kafka
      • Quick Start
    • Kubernetes
    • OpenShift
      • Manage Roles and Bindings
    • PostgreSQL
    • SSL / TLS
      • Common OpenSSL Commands
      • Create Self-signed Certificate
      • Java Truststore and Keystore
    • SSH
      • Key Management
      • Port Forwarding
    • YUM
      • List Repositories
      • List Packages
    • Miscellaneous
      • Network
Powered by GitBook
On this page
  • Without Root CA
  • With Root CA
  1. Commands
  2. SSL / TLS

Create Self-signed Certificate

Without Root CA

openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout server.key -out server.crt

With Root CA

  1. Create a root CA.

    # generate the private key
    openssl genrsa -out ca.key 2048 -nodes
    # generate the certificate
    openssl req -new -x509 -key ca.key -out ca.crt -days 3650

    -days: number of days the certificate will be valid for.

  2. Create a server private key and Certificate Signing Request (CSR).

    # generate the private key
    openssl genrsa -out server.key 2048
    # generate the CSR to be signed
    openssl req -new -key server.key -out server.csr
  3. Sign the CSR by the root CA.

    openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt

    -days: number of days the certificate will be valid for.

PreviousCommon OpenSSL CommandsNextJava Truststore and Keystore

Last updated 3 years ago