Search code examples
pythonsslcrate

Creating a CA certificate (.pem) file to connect to crate database


I am trying to connect to a crate database with python

from crate import client
url = '434.342.435.2:4400' # Faked these numbers for purposes of this post
conn = client.connect(url)

It seems like I need to pass the cert_file and key_file arguments to client.connect which point to my .pem and .key files. Looking in the documentation, I cannot find any resource to create or download these files.

Any advice? Even a comment pointing me to a good resource for beginners would be appreciated.


Solution

  • So cert and key files are part of the TLS encryption of a HTTP(S) connection that are required if you use a self-signed certificate :)

    This seems to be a very good explanation of the file types

    As mfussenegger explained in the comment, these files are optional and only required if your CrateDB instance is "hidden" behind a reverse proxy server like NGINX or Apache with a self-signed certificate. A small green lock on the far left of your browser's address bar indicates HTTPS (and therefore TLS) with known certificates. valid certificate

    Typically certificates signed by an unknown CA - like yourself - result in a warning page and a red indicator:

    invalid certificate

    Since you are also referring to username and password, they usually indicate some sort of auth (maybe basic auth) which is not yet supported by crate-python :(