No project description provided
Enables using requests without having to configure the CERN Root certificates.
Python 2.7 or
pip install cernrequests
Request a Grid User Certificate and convert into public and private key:
mkdir -p ~/private openssl pkcs12 -clcerts -nokeys -in myCertificate.p12 -out ~/private/usercert.pem openssl pkcs12 -nocerts -in myCertificate.p12 -out ~/private/userkey.tmp.pem openssl rsa -in ~/private/userkey.tmp.pem -out ~/private/userkey.pem
The certificates have to be passwordless.
import cernrequests url = "https://<your-cern-website>" response = cernrequests.get(url)
If you want to access a website which requires CERN Single Sign-on cookies you can do the following:
import cernrequests url = "https://<your-cern-website>" cookies = cernrequests.get_sso_cookies(url) response = cernrequests.get(url, cookies=cookies)
If you want to use
requests directly without the CERN wrapper you can get the exact same functionality by doing:
import requests from cernrequests import certs url = "https://<your-cern-website>" cert = certs.default_user_certificate_paths() ca_bundle = certs.where() response = requests.get(url, cert=cert, verify=ca_bundle)
The default user certificate paths are first
~\.globus\ for fallback. The default public key file name is
usercert.pem and the default private key file name is
You can configure the default grid user certificate path by setting the
CERN_CERTIFICATE_PATH environment variable.
This will still assume that your filenames are
Write this line in your
.bashrc to make the configuration persistent.
Alternatively you can also specify the paths directly in your code:
import cernrequests url = "https://<your-cern-website>" cert = "my/custom/path/cert.pem" # Public key path key = "my/custom/path/key.pem" # Private key path cernrequests.get(url, cert=(cert,key))
This way you can even use custom names such as
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for cernrequests-0.3.1-py3-none-any.whl