Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9253751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:17:51+00:00 2026-06-18T11:17:51+00:00

I am currently writing a python language plugin for a compiler I have written

  • 0

I am currently writing a python language plugin for a compiler I have written that automates http calls for a RESTful API. I have managed to get the login/authentication working using the socket and ssl modules, but this low-level approach seems to create potential problems with parsing the response in order to obtain the authentication token and secret. The requests module seems popular/efficient, however, I cannot seem to get it to function properly for my particular authentication needs. I am using a trust store in the form of a .pem file (containing just a public key) that I converted from my .jks file used to authenticate for the Java plugin. The server expects the username and password to be submitted in the request body in json format. Here is the code I have been trying to use:

#Server and login data
...
host = 'localhost'
port = 8443
pem_file = "C:\\Users\\aharasta\\pycert.pem"

#Digest password with MD5 algorithm
m = hashlib.md5()
m.update(password)
encrypted_password = m.hexdigest()

url = <url>
data = {'userid': user_name, 'password': encrypted_password}
json_data = json.dumps(data)
headers = {'Content-type': 'application/json', 'Accept': 'text/plain', 'Content \                     
          Length': len(json_data)} 

r = requests.post(url, headers = headers, data = json_data, cert = pem_file)
print(r)

Upon execution, this code will raise an SSL error stating “certificate verify failed”. If I add the parameter verify = False or verify = pem_file, I will receive a 404 response from the server. I should also note that when I launch the server in debug mode and execute the request (with one of the verify parameters), it never makes it to the server’s authentication methods, or any methods for that matter. Any insight or help on this matter would be greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:17:53+00:00Added an answer on June 18, 2026 at 11:17 am

    First there are a couple problems with what you posted:

    • You specify host and port but don’t give an example url, so we can guess that you’re using a local deployment for testing and can actually view the requests to the server. I’m not sure what methods you’re talking about, but if you’re using something akin to Flask for server development, you might not want to send the Authentication as JSON encoded data. There are Authentication headers for a reason, and requests has Authentication handlers for a reason. 😉

    • You shouldn’t specify the Content-Length header yourself. requests will do this for you. Beyond that, you’re specifying it incorrectly (according to what you posted), so the 404 may be from receiving a header your server doesn’t recognize.

    Now, there should be no reason to specify verify=False, and you can specify either cert=pem_file or verify=pem_file. Either or both should be fine but you should never use verify=False.

    Finally, the SSLError that is raised is telling you that the pem file you’re providing is not matching what the server is specifying it. With that in mind, you might want to check your local server’s settings. Requests doesn’t handle certificate verification itself, but urllib3 provides that. We just set it up based on the parameters you provide. And I doubt this is the fault of urllib3 since it raises an SSLError which arises from the standard library’s ssl module.

    Edit

    The explanation is in the documentation specifying a *.pem file with cert is invalid. You have to use verify='/path/to/file.pem' to do this correctly.

    Edit #2

    To inspect a request that was already sent you can do this:

    r = requests.post(...)
    r.request
    # PreparedRequest('POST', url, ...)
    r.request.body
    r.request.headers
    # etc.
    

    To modify a request before sending you can do the following:

    from requests import Request, Session
    
    s = Session()
    r = Request('POST', url, datajson_data, headers=headers)
    p = r.prepare()
    p.body = 'New body'
    p.headers = #etc.
    s.send(p, verify=pem_file)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the beginnings of a small multiplayer game that I'm writing in python
I'm writing what might not even be called a language in python. I currently
I am currently writing a security tool in python that runs as a daemon
I'm currently writing a serialization module in Python that can serialize user defined classes.
I am currently writing a non-web program using mostly python and have gotten to
I am currently writing a Python script for use on Linux machines that will
I am currently writing a rest API in python with the microframework Flask. It's
I'm currently writing a Python GDB script. The problem is that it has to
I'm currently writing several Python modules which perform some I/O. Thoses modules can be
I'm currently writing an app in Python and need to provide localization for it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.