Convert rsa keys into pem format

白昼怎懂夜的黑 提交于 2019-12-08 03:57:49

问题


I have an RSA keypair in decimal format like this:

N:  131380300130444423689465024460852313971098730922811994958210650530501686748132880102503190365296216968351535889369502651601697016994057094307459860310817213533755054007252477133258682280599098830508996183566745393684789271087614478241425320061726198137426426490142200235611844869472546908487777450913733956847
E:  65537
D:  80297204963989065579466889768824319637950465647088430322583084471355799970954766200860052948440422519604509972209521777162610037317804551817832746460011635684494412969232268215156141089492528372187753214602862715747188949826914338588271329247689858629892142371556575928454002581316958535707202236560574870513
P:  1224584489781086541356110467036625215751324632060784958572680296867401248241071907258999049522896850209985495153134079568147009917335592949603533318035603
Q:  10728561502026755927334064184961854822182870744919733441933716834397978727498603128211162084788541605856166966893670172798846339557261092973389679407794073

While OpenSSL (for PHP) requires that the key should be in PEM format. How do i convert them? It is very important that the public & private key "stays the same" (By that i mean that i can't just make a new keypair).

EDIT: Or is it easier to make a pem cartificate and extracting all of those values in decimal format? And if so, how?


回答1:


Short of doing it yourself (writing a small utitlity program to convert the key to PEM format) you could use the Java tool at this URL: http://www.platanus.cz/blog/converting-rsa-xml-key-to-pem

It requires the input to be in an XML file but that should be trivial for you to generate.




回答2:


Try ssh2openpgp in the monkeyspehere project.

UPDATE: Try also this. It explains how to go from, in two steps, OpenSSH → OpenSSL → GnuPG.



来源:https://stackoverflow.com/questions/8042911/convert-rsa-keys-into-pem-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!