Search code examples
meteoropenssl

"unable to load Private Key" error when try to open openssl private key file on mac


How can I open a private key created on a linux server from a Mac ?

Some context : I'm using a local script called mup to deploy a Meteor app which requires the openssl private key. I created the openssl private key on a linux ubuntu server I'm deploying to. I am deploying from my Mac OS 10.9.5.

The mup script throws this error : -----------------------------------STDERR----------------------------------- Trying to initialize SSL contexts with your certificatesError loading rsa private key -----------------------------------STDOUT-----------------------------------

So, the local mac can't open or access the private key. This command works on the ubuntu server where the key was created : openssl rsa -in private-key.nopass.key -check

However, If I run that same command on my local Mac on the same file ( which I copied and pasted from the terminal into Sublime text, with normal settings. ) , the local Mac throws this error :

unable to load Private Key ... routines:PEM_read_bio:no start line:pem_lib.c:701:Expecting: ANY PRIVATE KEY

So, I'm assuming the mup error has something to do with this.
On the local mac the openssl version is OpenSSL 1.0.2f 28 Jan 2016. On the remote linux server the openssl version is OpenSSL 1.0.1f 6 Jan 2014.


Solution

  • so, the good folks at namecheap.com support helped me with this question. Turns out I was missing one dash!! haha.

    This (4 dashes):

    ----BEGIN RSA PRIVATE KEY-----
    

    Should have been this (5 dashes):

    -----BEGIN RSA PRIVATE KEY-----
    

    The takeaway is count your dashes when manually copying/pasting these files! It's far too easy to mistake four dashes for five.