magnuswatn / certsrv

A Python client for the Microsoft AD Certificate Services web page
MIT License
79 stars 26 forks source link

Client not authorised. #15

Closed pbulteel closed 4 years ago

pbulteel commented 4 years ago

I'm adding the capability to talk to the MSCA to a script. The part that uses the Certsrv component causes an error.

I get:

File "/usr/lib/python2.7/dist-packages/requests/models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://pki.example.com/certsrv/certfnsh.asp

When I look at the server weblogs, I see that requests that work correctly (from WebUI or other scripts) include the username in the weblog (so they're in the request), but requests from the certsrv component do not.

I am using Certsrv.get_cert(csr, "WebServer", encoding="b64") -- after instantiating the object with the server, username and password.

I've tried using the examples, but they give the same error.

The user used for this has the ability to create, sign and receive the certs as this is what I use in the other scripts and the WebUI.

So - am I missing something?

Certsrv version 2.1.1. Python version 2.7.16

Thanks,

Patrick

pbulteel commented 4 years ago

It turns out that I needed to set auth to NTLM. Now I get a different error but that's due to the server permissions.