Suren
Suren

Reputation: 47

crypto.load_certificate() throws 'no start line'

I am trying to open an encoded X509 certificate using the following command


!/usr/bin/python

from OpenSSL import crypto, SSL

crypto.load_certificate(crypto.FILETYPE_PEM, 'ca_file.pem')

But after execution I get the following error

Traceback (most recent call last): File "cert_from_sign_req.py", line 13, in "ca_file.pem") File "build/bdist.linux-x86_64/egg/OpenSSL/crypto.py", line 1511, in load_certificate File "build/bdist.linux-x86_64/egg/OpenSSL/_util.py", line 48, in exception_from_error_queue OpenSSL.crypto.Error: [('PEM routines', 'PEM_read_bio', 'no start line')]

Can someone help me to understand what is the problem?

Upvotes: 0

Views: 4498

Answers (1)

Suren
Suren

Reputation: 47

Already found the reason. My sample code was written using article in docs.genati.org http://docs.ganeti.org/ganeti/2.14/html/design-x509-ca.html but apparently there was a mistake. Problem was that the last argument should be buffer of file and not the path location. It should be crypto.load_certificate(crypto.FILETYPE_PEM, file('ca_file.pem').read())

Upvotes: 1

Related Questions