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

Certificate/SSL based authentication #10

Open
CsBigDataHub opened this issue Jun 15, 2021 · 2 comments
Open

Certificate/SSL based authentication #10

CsBigDataHub opened this issue Jun 15, 2021 · 2 comments

Comments

@CsBigDataHub
Copy link

CsBigDataHub commented Jun 15, 2021

How do I replicate these commands when creating reqman.conf ?

Essentially enable ssl/certificate based authentication for all my calls?

curl -k https://www.thesitetoauthenticate.com/test -v –key key.pem –cacert ca.pem –cert client.pem
curl --cert-type P12 --cert cert.p12:password https://yoursite.com
curl -E ./file.crt.pem --key ./file.key.pem https://myservice.com/service?wsdl

Thanks

@CsBigDataHub
Copy link
Author

CsBigDataHub commented Jun 15, 2021

When requests package is used, SSL/certificate based authentication can be achieved like below

def post(url, schema):
    headers = {"Content-Type": "application/json"}
    content_body = {"data": data}
    print("registering schema at url: ", url)
    CACERT = os.path.abspath("../../cert.pem")  # Server certificate chain
    CERT = os.path.abspath("../../cert.crt")  # Client certificate
    KEY = os.path.abspath("../../cert.key")  # Client private key
    try:
        session = requests.Session()
        session.cert = (CERT, KEY)

        r = session.post(url,
                         data=json.dumps(content_body),
                         headers=headers,
                         verify=CACERT)
        print("response status code: ", r.status_code)
        print("response status code: ", r.reason)
        print("response status code: ", r.text)
        if r.status_code >= 300:
            sys.exit(1)
    except requests.exceptions.RequestException as e:
        print(e)
        sys.exit(1)

@CsBigDataHub CsBigDataHub changed the title Certificate based authentication Certificate/SSL based authentication Jun 16, 2021
@manatlan
Copy link
Owner

currently ... reqman bypass totally the SSL part : all requests are "unverified" !
There is no ways to play with certificates/keys ...

Currently it uses the aiohttp module, but plans to go with httpx (when it will support socks proxy (needed at my job)) ... (can't use requests, coz it miss async support)
When It will move to httpx, I could plan to use ssl verifications (but it will definitly complexify the thing !)

But sure, it can be more valuable to be able to tests ssl keychains.

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

No branches or pull requests

2 participants