I have the following code in C# which does the job I need it to:
//Try create an X509 cert object
X509Certificate x509Cert = new X509Certificate("C:/Users/mryan/Documents/Code/SampleApps/bundle.p12", "passphrase");
//Serialize Cert and POST to server
string devString = Newtonsoft.Json.JsonConvert.SerializeObject(x509Cert);
result = wc.UploadString(apiRoot + "/Accounts/" + accId + "/certs", "POST", devString)
So here, devString
would be equal to:
"{\"RawData\":\"MIICiTCCAfKgAwI...OhpEV23wsm06G2s5OJk=\"}"
As far as I can tell, RawData
is a property in x509Cert which equals an array of bytes.
Is there any obvious module in python that can achieve the same result? I was looking at this answer but I can't tell if it reflects what I want to achieve.
Desirable Python Pseudocode:
#Create X509 Cert object
x509cert = module.readX509Certificate("C:/Users/mryan/Documents/Code/SampleApps/bundle.p12", "passphrase")
cert_data = {"RawData": x509Cert}
result = requests.post(apiRoot + "/Accounts/" + accId + "/certs", data=cert_data)
Any ideas about how to handle this would be great!