Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use caCertificatePemFile in OpenSSL backend #1047

Merged
merged 4 commits into from
Nov 23, 2023

Conversation

sebihoefle
Copy link
Contributor

This PR considers the caCertificatePemFile for the OpenSSL backend, allowing to accept self-signed certificates, useful for local development (https://letsencrypt.org/docs/certificates-for-localhost/#for-local-development).

Expected:
Self-signed certificates should be accepted if the client adds the certificate as verified.

Example:

Creation of certificates:

openssl req -x509 -out localhost.crt -keyout localhost.key \
  -newkey rsa:2048 -nodes -sha256 \
  -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

Server side:

  WebSocketServer::Configuration serverConfig;
  serverConfig.port = 48080;
  serverConfig.enableTls = true;
  serverConfig.certificatePemFile = "localhost.crt";
  serverConfig.keyPemFile = "localhost.key";
  serverConfig.bindAddress = "localhost";

Client:

  WebSocket::Configuration config;
  config.disableTlsVerification = false;
  config.caCertificatePemFile = "localhost.crt";
  WebSocket ws(config);

@sebihoefle
Copy link
Contributor Author

Thanks @paullouisageneau , wasn't aware of SSL_CTX_load_verify_locations in [email protected].

@paullouisageneau paullouisageneau merged commit cafd410 into paullouisageneau:master Nov 23, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants