Answer the question
In order to leave comments, you need to log in
Tweaking OpenSSL Settings
The OpenSSL library keeps all the default settings in the openssl.cnf
file.
There are a bunch of all sorts of parameters, many of which are completely optional.
I tried to comment on most of them - everything worked fine.
But, everything (key generation, certificate signing) stopped working
after I completely deleted this file from the OpenSSL library folder.
Some things (such as key generation) started working again after
I created an empty openssl.cnf file with some trivial content.
Kind people suggested how you can still do without this file at all:
<?php
$config["config"] = "nul"; // "openssl.cnf";
$config["private_key_bits"] = 384; // 1024;
$config["private_key_type"] = OPENSSL_KEYTYPE_RSA;
$config["encrypt_key"] = false;
$config["digest_alg"] = "default"; // "sha1";
$privkey = openssl_pkey_new($config);
// That is, you just need to set the config parameter to "nul". $dn["countryName"] = "RU";
$dn["stateOrProvinceName"] = "Vladimirskaya";
$dn["localityName"] = "Vladimir";
$dn["organizationName"] = "Habrahabr";
$dn["organizationalUnitName"] = "Habr";
$dn["commonName"] = "1010101001000100110100111";
$dn["emailAddress"] = "[email protected]";
$csr = openssl_csr_new($dn, $privkey, $config);
var_dump($csr);
The result was: bool(false)
Answer the question
In order to leave comments, you need to log in
Generally speaking, OpenSSL support in PHP is poorly implemented. Instead of wrapping standard OpenSSL functions, they started reinventing the wheel by nailing crutches. As a result, this support turned out to be raw, and is unlikely to ever become normal.
All this is complemented by partially erroneous/outdated documentation on these php's functions. I would recommend abandoning this disastrous idea and writing in something more kosher. If you still want to use php, I recommend looking at the PHP sources, instead of manuals - they are more reliable.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question