Getting public key using openssl_*

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • diogoko

    Getting public key using openssl_*

    Has anyone been sucessful in getting/reading a RSA or DSA public key
    using the openssl functions?

    openssl_get_pub lickey should work with PEM files, but it doesn't...

    I've tried creating a X.509 certificate, putting the public key in
    there and getting it out with openssl_get_pub lickey, but it doesn't
    work either...

    All I want to do is to decrypt some data using a public key received
    from the user. Ideas?

  • diogoko

    #2
    Re: Getting public key using openssl_*

    > openssl_get_pub lickey should work with PEM files, but it doesn't...

    Actually it does, if you give it the key in the right format. Something
    like:

    -----BEGIN PUBLIC KEY-----
    MIGfMA0GCSqGSIb 3DQEBAQUAA4GNAD CBiQKBgQCuI6b3a uKaUF67XLchzhhf nhsw
    r3MsxQ3mjJsN7cq 96RwIiaUgOtm0re vhQB4JX0m1x1uI4 GzTevMsRKZepNnt 5lvi
    UXaZ8ztl4ryvKVz YdqfooJI78jRsP//Ss8gWeq7/No9xTdY9jWUKS6Z w01v6C77h
    tCv22DfDf5gGRfc q1wIDAQAB
    -----END PUBLIC KEY-----

    I managed to create the public key from the private key using the
    openssl command line tool:

    $ openssl rsa -in private_key -pubout -out public_key

    Comment

    Working...