1
1
10101010010001001101001112011-12-16 09:29:30
OpenSSL
1010101001000100110100111, 2011-12-16 09:29:30

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".
// But, my further independent steps did not lead to success:
$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)

What else is missing for complete happiness?
That is, what configs still need to be set?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kolobob, 2011-12-16
@kolobob

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 question

Ask a Question

731 491 924 answers to any question