Skip to content
Advertisement

openssl_pkey_new() throwing errors — Proper openssl.cnf setup for php

**Okay, It’s become clear that this issue is an issue related with the setup of openssl on the Linux server and how to properly setup a custom openssl.cnf file. I am not looking for anything complicated but I need a front-end to be able to create self-signed client certificates for authentication to my webservice. So I need to be able to use my CA to create intermediate CAs for client companies and then allow them a secure interface to issue client certificates for their employees. Logins are based on whether you belong to a specific intermediate CA and that your certificate or the intermediate CA hasn’t be revoked.

For anyone wondering, we can use self-signed certificates because they are only used for our server to authenticate users and since we issued them, we trust them. Also it would be way too expensive for a startup to establish themselves as an intermediate CA through the commercial offerings AFAIK. Microsoft can do that, we can’t. Our webserver itself uses a CA signed certificate.

I know that php code for setting this kind of thing up is straight forward but what isn’t is how to properly setup openssl. I have tried several different examples on the net and none of them seem to work for my setup and they all seem to be different. One box was fresh install of Centos 6.2 and I am still getting errors.

Can anyone point me in the proper direction for setting up openssl, apache2 and php so that I can use these php libraries without errors? Our virtual server is using debian squeeze and I have full control of software installed.

Thanks.

open_pkey_new() is returning errors such as error:0E06D06C:configuration file routines:NCONF_get_string:no value. Yet I am passing a path to a openssl.cnf file so I don’t know why I’m still getting this problem. Here’s my relevent code

JavaScript

Here’s my function that makes the keys.

JavaScript

I’ve tried relative paths too to the configfile and it still won’t work. Looks like it might be the host providers ssl setup. I switched to a local virtual machine and I got the key to generate but now I’m getting the same error when creating a csr.

error:0E06D06C:configuration file routines:NCONF_get_string:no value

JavaScript

openssl.conf This looks to be an error in openssl.cnf so I’ve included the file.

JavaScript

Stack trace strace php getkeystore.php &> stack.trace

http://secure.g4apps.com/generator/stack.trace

Advertisement

Answer

I tried this on my Mac and a fresh install of CentOS 6.3 and I’m getting the same error. I get my CentOS packages from IUS. It’s weird though because even though I’m getting this message, the key is actually being generated.

The following code:

JavaScript

Gives me the following output:

JavaScript

I suspect it being a bug in PHP. Some sort of openssl configuration PHP is getting hung up on. I found a bug report about this on php.net, but it “started working” for the user so the bug was closed.

As an alternative, you can check out phpseclib, a library purely written in PHP.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement