Jose_Sunstrider
Jose_Sunstrider

Reputation: 323

Get a Public Key from Python String (SHA)

Let's say that I have a python string:

string_full = """
              -----BEGIN CERTIFICATE----- 
              GIBBERISH................
              ......................
              ........................
              -----END CERTIFICATE-----
              """

After removing the first line, newlines, and last line I got something like this:

 string = """ GIBBERISH .................................. """

What I'm trying to do is to get the Public Key from that certificate.

I was having a look at this post, but it seems that the string must be formated as string_full but the real problem is that I'm reading that line from a user uploaded file (django), but since this file is structured by the Mexican Goverment, it would be really easy for me to calculate the public key from the string as shown in string. a Got any ideas? I was having a look at M2Cryptolib which implements a get_pukeybut it will only work on requests and I have no way to get this request from an external server.

Any help would be appreciated.

Upvotes: 0

Views: 527

Answers (1)

JasonPap
JasonPap

Reputation: 98

I'm not sure why you are trying to get that string since to my knowledge most ssl functions will take the whole cert to verify.

Have you seen this post? It looks like what you want.

Hope that helps.

EDIT:

I think this example will help you understand what's every argument and in what format should it be.

Upvotes: 1

Related Questions