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 7739503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:32:24+00:00 2026-06-01T08:32:24+00:00

I am having difficulties debugging a django/python application that requires a public key to

  • 0

I am having difficulties debugging a django/python application that requires a public key to be used to sign a certificate.
1. I created a key in PEM format from my private key using the following command

openssl rsa -pubout -in ~/.ssh/id_rsa > samplePEMKey.pub

The key is given below

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8K/LfOBi+QrINSseqWwc
JGo4uE49Dc42zF2Jwbmc6iXIln8AWX5M+yn15dYOXzbHGbopH8bpF9CsJ/DPHg87
D1At1XwAy5aR5w7pXE//5p/saW50Sm/eY6Nugs9hgAXUTcMMAEXCIG17dLoUzhwE
YdzuPm350h39bTmI7Fz95koTbsKJUi+6337GJ3cWKxMBkEmWvpGo4Nko01xtEnUZ
GweKexr1roE8jZPpzuNeUy+S5tvH5emyBIBdroBVxBtz1OUIoP0oAOrQ5RtRPAcT
TsSWjMtyF2gO5GxeMErRqnLAtWJs4QlaJacVnMMTAgRjrGkUZdsqngM/fjQXfeZV
SwIDAQAB
-----END PUBLIC KEY-----

In my python app I am using OpenSSL and trying to load the key using

pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, samplePEMKey)

When running the django app I get the following error at the above line.

Request Method:     POST
Request URL:    http://127.0.0.1:8000/snapshotuploader/single/
Django Version:     1.3.1
Exception Type:     Error
Exception Value:    

[('PEM routines', 'PEM_read_bio', 'no start line')]

Here’s how I read the public key from the file

    file_path = '/home/XXXX/co/certserver/LicenseServer/home_folder/dldl/samplePEMKey.pub' 
try: 
  fin = open(file_path, 'r') 
except IOError: 
  return HttpResponse('IO Error opening uploaded file.') 
try: 
  samplePEMKey = fin.read() 
  fin.close() 
except IOError: 
  return HttpResponse('IO Error reading uploaded file.') 

Appreciate any help in solving this issue. Thanks in advance.

  • 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-01T08:32:25+00:00Added an answer on June 1, 2026 at 8:32 am

    Took a while to spot it, but you are trying to read a public key with a private key method. If you want to use load_privatekey you should use the original id_rsa as input.

    I don’t remember how to do the same with OpenSSL.crypto, but at least with the pycrypto toolkit’s RSA implementation your sample key imports just fine:

    >>> kt = open("samplePEMKey.pub").read()
    >>> from Crypto.PublicKey import RSA
    >>> key = RSA.import_key(kt)
    >>> key
    <_RSAobj @0x109916d40 n(2048),e>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having difficulties handling multiple instances of my root (main) activity for my application.
I'm having difficulties working with some legacy enums that have multiple zero values. Whenever
I'm having difficulties with an MFC application menu drop down. I want the drop
I am having difficulties importing a script from a directory that is not stored
I am having difficulties trying to solve a runtime error that I get in
I am having difficulties in retrieving 50 results from google. I'm using this: public
I'm having difficulties passing an apostrophe into my autocomplete. The database contains entries that
I'm having difficulties with a set of activeX controls used for automation of lab
I am having difficulties with a program that I have been working on all
I am having difficulties with pages that have more than one <audio> when I

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.