Answer the question
In order to leave comments, you need to log in
How to generate a client certificate (PKCS12) in Java?
Good afternoon
Guys, please help, I re-read all the docks, but I just can’t
figure it out How to generate self-signed certificates in runtime in Java. I found the bouncy castle library, but I just can’t
figure it out Or even like this: how in Java you can write such logic as in php:
private function generate_pkcs($secret) {
$dn = [
'countryName' => 'RU',
'commonName' => 'client'
];
$options = [
'private_key_bits' => 1024,
'private_key_type' => OPENSSL_KEYTYPE_RSA,
'encrypt_key' => FALSE
];
$client_key = openssl_pkey_new($options);
$csr = openssl_csr_new($dn, $client_key, $options);
$serial = time();
$client_crt = openssl_csr_sign($csr, $server_crt, $server_key, 50000, $options, $serial);
$out = NULL;
openssl_pkcs12_export($client_crt, $out, $client_key, $secret);
$result = [
'serial' => $serial,
'pkcs12' => $out
];
return $result;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question