aiohttp compatible pynacl middleware
Project description
Starting
To start, clone the project with:
git clone https://github.com/CosmicDNA/nacl_middleware
Then enter the cloned folder and create a new virtualenv:
cd nacl-middleware
python3 -m venv .venv
Activate the just created virtualenv with:
. .venv/bin/activate
Install the dependencies with the command:
pip install -e .[test]
Testing
Run the test suite with the command:
pytest -s
Testing with SSL
Certificates Creation
![NOTE] The following topics consider the project's root folder as the working directory.
Generate a Client Key and Certificate Signing Request (CSR)
To generate a client key and CSR, run openssl
command in the terminal:
# Generate a private key (client.key)
openssl genpkey -algorithm RSA -out client.key
# Create a certificate signing request (client.csr)
openssl req -new -key client.key -out client.csr
Generate Self-Signed SSL Certificates
For the server, generate the self signed certificates with:
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout selfsigned.key -out selfsigned.crt
You will be prompted to answer some questions during the certificate generation process. Make sure to set the Common Name (CN) to your server’s domain name (e.g., localhost).
Sign the CSR using your CA's private key
Lastly, sign the CSR using the server's CA's private key
openssl x509 -req -in client.csr -CA selfsigned.crt -CAkey selfsigned.key -CAcreateserial -out client.crt -days 365
Configuration
Once a pytest run has generated a config.json
file, you can edit it and add:
{
"ssl": {
"cert_path": "selfsigned.crt",
"key_path": "selfsigned.key"
}
}
You should now be able to perform the test with SSL enabled.
pytest -s
![TIP] Removing the
ssl
section from config.json deactivates SSL within both client and server modules.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for nacl_middleware-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac509ea475580d30c30118fd2277272f781790aab87a0c2ed7a55d1241a653f9 |
|
MD5 | 88eb4956951673991b293d764d1c29b5 |
|
BLAKE2b-256 | a8f3e57639e29a56de6c9321ec21e6ed3dacbbf3f4c7af434b69d77eeb5683e9 |