Giter Site home page Giter Site logo

mutual-tls-example's Introduction

To generate a test key and certificate (crt) file for testing purposes, you can use OpenSSL, a widely-used open-source toolkit for working with SSL/TLS protocols. Below are the steps to generate a self-signed certificate along with a private key:

Step 1: Install OpenSSL

Make sure you have OpenSSL installed on your system. You can download OpenSSL from the official website or install it using a package manager relevant to your operating system.

Step 2: Generate a Private Key

Open a terminal or command prompt and run the following command to generate a private key:

openssl genpkey -algorithm RSA -out key.pem

This command generates an RSA private key and saves it to a file named key.pem.

Step 3: Generate a Certificate Signing Request (CSR)

Next, create a Certificate Signing Request (CSR) with the following command:

openssl req -new -key key.pem -out csr.pem

You will be prompted to enter information such as the Common Name (CN), organization, and others. The Common Name is typically the domain name for which you are creating the certificate. For testing purposes, you can use something like "localhost" as the Common Name.

Step 4: Generate a Self-Signed Certificate

Now, use the CSR to generate a self-signed certificate:

openssl x509 -req -in csr.pem -signkey key.pem -out cert.pem

This command generates a self-signed certificate (cert.pem) using the private key (key.pem) and the CSR (csr.pem).

Step 5: Verify the Certificate

You can verify the contents of the certificate using the following command:

openssl x509 -text -noout -in cert.pem

This will display detailed information about the certificate.

Now, you have a test key (key.pem) and a self-signed certificate (cert.pem) that you can use for testing purposes. Keep in mind that for production use, you should obtain certificates from a trusted Certificate Authority (CA).

for app in client server
do
  openssl genpkey -algorithm RSA -out ${app}-key.pem
  openssl req -new -key ${app}-key.pem -out ${app}-csr.pem
  openssl x509 -req -in ${app}-csr.pem -signkey ${app}-key.pem -out ${app}-cert.pem
done


mutual-tls-example's People

Contributors

stevenhankin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.