1
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
2
<title>ReplacingCertificates - OpenSC - Trac</title><style type="text/css">
4
</style></head><body><div class="wikipage">
5
<div id="searchable"><h1 id="Replacingacertificateonacard">Replacing a certificate on a card</h1>
7
Unfortunatly not all cards allow to replace a certificate with a new one.
8
Here is a small HOWTO for Aladdin eToken PRO (should work with any cardos card).
11
1. Create a new certificate. If it's a self signed certificate, don't forget to add the -days attribute, else you'll have to do this process very often.
14
2. If you have the certificate PEM encoded (this is very likely if you use the default settings of openssl) then convert it to DER encoded:
16
<pre class="wiki" xml:space="preserve">$ openssl x509 -in mycert.pem -outform DER -out mycert.der
18
3. Now get the path of the certificate:
20
<pre class="wiki" xml:space="preserve"> $ pkcs15-tool -c
21
X.509 Certificate [Certificate]
28
The path here is: 3F0050154301
31
4. open up opensc-explorer
33
<pre class="wiki" xml:space="preserve">OpenSC > cd 5015
35
5. present the valid key for the certificate file, usually the normal pin. You can get info about wich pin to use by executing:
37
<pre class="wiki" xml:space="preserve">OpenSC > info [EF]
39
where [EF] is the name of the cert EF (in the above example 4301)
42
You'll need the key in hexadecimal format, an example how to convert it:
44
<pre class="wiki" xml:space="preserve"> $ export HISTFILE=
45
$ php -r 'echo bin2hex("pssword")."\n";'
48
You'll have to add the colons manually. If your password is shorter than 8 characters, fill it up with 00-s. So with the above example you enter at the opensc-explorer:
50
<pre class="wiki" xml:space="preserve">OpenSC > verify CHV3 70:73:73:77:6f:72:64:00
55
6. Now you can load the data from the DER encoded file into the EF on the card:
57
<pre class="wiki" xml:space="preserve">OpenSC > put 4301 mycert.der
59
If you get no errors, then you're done.
64
<ul><li>This isn't the preferred way for everyday users to replace the certificates. Maybe this isn't even for the user's mailing list, but I couldn't find any description how to solve this dangerous yet very urging problem.
65
</li></ul><ul><li>This may not work on some cards.
66
</li></ul><ul><li>Since the key isn't changed, after replacing the old certificate you
68
_won't_ need to replace your .eid/authorized_certificates, or .ssh/authorized_keys files.
70
<ul><li>I had to delete the contents of the .eid/cache/ directory for Mozilla to see the new certificate correctly.
72
Thanks to Attila Nagy for this information.
75
</div><div class="footer"><hr></hr><p><a href="index.html">Back to Index</a></p></div></body></html>