PHP stream_context_set_option SSL certificate as string -


I have found a strange problem. Actually, I need to:

  $ Handle = stream_context_create (); Stream_context_set_option ($ handle, 'ssl', 'local_cert', '/ tmp / cert');   

Although the certificate is not placed as a file within the server, instead it is an encrypted string that is held in the cluster database environment. Therefore, instead of being a filename indicator, the physical content of its authenticity. So instead of using the filename, I need to specify the content of the certificate instead.

For example:

  $ cert = '----- BEGIN certificate ----- up WbwmdMd61SjNCdtOpZcNW3YmzuT96Fr7GUPiDQ ----- end certificate --- - ';   

Does anybody have any idea how can I do this on earth? I am scratching my head on this problem, but my gut instinct says that it is possible.

Thanks everyone!

As Marilyn said, the only way to do this is to write the certificate from memory in a temporary file Will call the function, request it, and then remove the temporary file.

I looked at the PHP source code (relevant code) and when you make a request that will use SSL, it checks to see if the local_cert reference option is set , And if so, eventually calls the OpenSSL function which reads the certificate from the disk file.

Note that the file is not read until the request is made, so you can not delete your template file until after stream_context_set_option call As requested, it has been requested.

Comments