1
0
mirror of https://github.com/actix/examples synced 2024-11-24 06:43:00 +01:00
examples/https-tls/openssl
2023-07-18 16:26:47 +01:00
..
src update mkcert command 2023-05-22 14:18:07 +01:00
Cargo.toml use secure version ranges 2023-07-18 16:26:47 +01:00
cert.pem show how to handle private keys with passphrases in openssl example 2023-05-22 14:06:04 +01:00
key.pem show how to handle private keys with passphrases in openssl example 2023-05-22 14:06:04 +01:00
README.md better HTTPS readmes 2023-05-22 14:21:48 +01:00

HTTPS Server using OpenSSL

Usage

Generating Trusted Certificate

We put self-signed certificate in this directory as an example but your browser will complain that connections to the server aren't secure. We recommend to use mkcert to trust it. To use a local CA, you should run:

mkcert -install

If you want to generate your own private key/certificate pair, then run:

mkcert -key-file key.pem -cert-file cert.pem 127.0.0.1 localhost

A new key.pem and cert.pem will be saved to the current directory. You will then need to modify main.rs where indicated.

Running Server

$ cd security/openssl
$ cargo run # (or `cargo watch -x run`)
starting HTTPS server at 127.0.0.1:8443

Using Client

  • curl: curl -vk https://127.0.0.1:8443
  • curl (forced HTTP/1.1): curl -vk --http1.1 https://127.0.0.1:8443
  • browser: https://127.0.0.1:8443

Self-Signed Encrypted Private Key Command

openssl req -x509 -newkey rsa:4096 -keyout key-pass.pem -out cert-pass.pem -sha256 -days 365