Skip to main content

PHP, Openssl and the private key

This blog post might be outdated!
This blog post was published more than one year ago and might be outdated!
· One min read
Stephan Hochdörfer
Head of IT Business Operations

Just as a side note, since I lately got some trouble passing the private key to the openssl_pkey_get_private() function. I was following a hint on the net but I did not succeed. The reason was a slight misunderstanding on my side: You can pass the private key to the function in two ways: Either a string containing the private key or a string containing location of the private key file on the harddisk. The latter one was the one I was struggling with. In case you want to use a file that contains the private key you need to pass the protocol identifier. If the protocol identifier is missing the function seems to think the string contains the private key, not the location of the private key. So, if you want to refer to the file /tmp/private.key the string needs to look this: file:///tmp/private.key