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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:00:31+00:00 2026-05-26T19:00:31+00:00

I am trying to export a public key from openssl using python. I have

  • 0

I am trying to export a public key from openssl using python. I have the actual key information transferred to the client from the server but the PEM encoding is not transferred so the key on the client is useless. I basically send the public key using send all in python but unfortunately this does not send the PEM encoding. Does anyone know how to transfer the encoding?
I didn’t know that the encoding would not transfer along with the key.

THe code where the string is read in

 import socket

 import M2Crypto as m2c
 import os

 max_transfer_block = 1024
 server_addr = "10.1.1.2"
 dest_port = 3333
 listen_port = 8888
 client_addr =  "10.1.1.3"
 mysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 mysocket.connect((server_addr, dest_port))

 #receive the public key from the server
 keysocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 keysocket.bind((client_addr, listen_port))
 keysocket.listen(1)
 conn, client_addr = keysocket.accept()
 print 'connected by', client_addr
 data = conn.recv(max_transfer_block)
 #FILE = m2c.RSA.save_pub_key(data, "serverPubKey.pem")

 FILE = open("sPub.pem", "w")
 FILE.write(data)
 keysocket.close()     

 #transfer encrypted file
 key = m2c.RSA.load_pub_key('serverPubKey.pem')
 FILE = open("test.txt", "r")

 data = FILE.read()

 encrypted = key.public_encrypt(data, m2c.RSA.pkcs1_padding)

 mysocket.sendall(encrypted)
 mysocket.close()

When I use the line key = m2c.RSA.load_pub_key('serverPubKey.pem') I get an error telling me that there is no starting point.

 raise RSAError, m2.err_reason_error_string(m2.err_get_error()) M2Crypto.RSA.RSAError: no start line

I have figured out that this is because there is not in PEM format. Unfortunately, I don’t know how to put it in that format.

  • 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-05-26T19:00:32+00:00Added an answer on May 26, 2026 at 7:00 pm

    The mistake was that the public/private key pair needs to be created from the same wrapper. What I mean by this is that not all key pairs are the same. My specific problem was that Openssl and the M2Crypto instances of key pairs were not in the same underlying format. Thus creating keys with Openssl and then trying to use M2Crypto to use the keys was wrong. The lesson from all of this is to not import keys from other wrappers. If you do, make sure that they are in the same underlying format like ASCII or Unicode before trying to use them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an actionscript file that I am trying to export from Adobe Flash
I have a j2ee application using spring framework. I am trying to export jasper
Im trying to export a .dmp of an oracle database but am getting the
I'm trying to export a Crystal Report to an HTML file, but when I
I'm trying to export the schema of my database so another developer can have
I am trying to export the following data in the query from ms sql
I'm trying to export a copy of the Explain Plan from Oracle SQL Developer
I'm currently trying to export gridview to pdf file. My code is: public void
I'm trying to export a global variable from a DLL. Foo.h class Foo {
I am trying to use MEF to Export the following: [Export(typeof(IRepository<>))] public class Repository<T>

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.