|
|
||||||||||||||
|
|
English text below
Zertifikatsverwaltung mit OpenSSL
Hier sind die wichtigsten Befehle und Abläufe zum Umgang mit Zertifikaten aufgeführt.
Bei einigen Anweisungen sind im Einzelfall zusätzliche Optionen notwendig. In jedem Fall
ist die Manpage zu openssl und die Java-SDK-Doku für weitere Information heranzuziehen.
Please take a look at the myCA-project English text below 1. Zertifikat erstellen: Java: keytool -genkey -alias reinhardX keytool -certreq -alias reinhardX -file reinhardX.csr OpenSSL: openssl req -new -out reinhardX.csr -keyout reinhardX.key 2. CA-Zertifikat importieren: Java: keytool -import -alias myca -file cacert.pem 3. CA signiert Request OpenSSL: openssl ca -policy policy_anything -days 365 -in reinhardX.csr -out reinhardX.pem 4. Zert. importieren (wenn es in OpenSSL erstellt wurde): Java: (Erst in der Datei reinhardX.pem alle Zeilen vor BEGIN CERTIFICATE löschen!) keytool -import -file reinhardX.pem -alias reinhardX 5. Zert. zurückrufen (als ungültig erklären) openssl ca -revoke reinhardX.pem 6. CRL erstellen: openssl ca -gencrl -out 2002-08-01.crl (Diese CRL muss für jeden Nutzer der Zertifikate zugänglich sein. Gültigkeitsdauer beachten) 7. Export aus Java keytool -export -alias reinhardX -file reinhardX.pem -rfc (Private-Key ebenfalls in reinhardX.pem) 8. Internet-Explorer-Zertifikat nach Linux portieren: openssl pkcs12 -in ReinhardX.pfx -out ReinhardX.pem (Private-Key ebenfalls in reinhardX.pem) 9. Umgekehrt: openssl pkcs12 -export -name DisplayNameInListBox -in cert.pem -inkey key.pem -out ie.pfx (Datei ie.pfx dann in Internet-Explorer importieren) Hinweise: ========= Die PEM-Dateien von OpenSSL enthalten oft Texte ausserhalb der BEGIN-END-Blöcke. Viele Programme wie z.B. keytool vertragen das nicht. Entweder per Hand löschen oder so filtern: openssl x509 -in reinhardX.pem -out reinhardY.pem English version:
Here are some examples for the usage of openssl
an keytool for managing certificates.
Please take a look at the myCA-project
1. generate a new certificate ("certifcate request")
Java:
keytool -genkey -alias reinhardX
keytool -certreq -alias reinhardX -file reinhardX.csr
OpenSSL:
openssl req -new -out reinhardX.csr -keyout reinhardX.key
(Now you have a private key in 'reinhardX.key' (openssl)
or in your keystore (java) and a cert request in 'reinhardX.csr'.
This cert request has to be signed by a trustcenter)
2. import a CA ("certifcate authority") certificate from your trustcenter:
Java:
keytool -import -alias myca -file cacert.pem
3. When you are your own trustcenter: sign a cert request (from 1.)
OpenSSL:
openssl ca -policy policy_anything -days 365 -in reinhardX.csr -out reinhardX.pem
(Now you have a valid certificate in 'reinhardX.pem')
4. import a certificate from openssl into keytool:
(you have to create a new text file, which contains the cert from 'reinhardX.pem'
_and_ the private key from 'reinhardX.key'.
It has to be like this:
BEGIN CERTIFICATE
some lines of blablabla
END CERTIFICATE
BEGIN RSA PRIVATE KEY
some lines of blablabla
END RSA PRIVATE KEY
Do _not_ include the extra text which is inserted by openssl.
Save the text file as 'cert_with_key.pem')
Java:
keytool -import -file cert_with_key.pem -alias reinhardX
5. a CA can revoke a certificate (make it invalid)
openssl ca -revoke reinhardX.pem
6. create a list of invalid certificates: ("CRL")
openssl ca -gencrl -out 2002-08-01.crl
(this CRL has to be distributed to all user of the certificates of this CA.)
The CRL has a expiration date, create a new one before expiry!)
7. export a cert with private key from keytool for external use:
keytool -export -alias reinhardX -file reinhardX.pem -rfc
(Attention: the private key is in the file 'reinhardX.pem'.
Be careful with it!)
8. you can use a cert from Internet Explorer with openssl:
Convert it from *.pfx to *.PEM:
openssl pkcs12 -in ReinhardX.pfx -out ReinhardX.pem
(Private-Key ebenfalls in reinhardX.pem)
9. and vice versa:
openssl pkcs12 -export -name DisplayNameInListBox -in cert.pem -inkey key.pem -out ie.pfx
(you can import 'ie.pfx' in Internet Explorer)
Note about the file format:
==========================
The *.pem-files generated by openssl often contain some extra text outside the
BEGIN .... - END ... - blocks.
Java keytool cannot cope with those.
You can manually delete the garbage. To do it automatically, you use:
(for certs)
openssl x509 -in reinhardX.pem -out reinhardY.pem
(for private keys)
openssl ras -in key1.pem -out key2.pem
I hope you find this information useful. Please send me your feedback to: rm@moosauer.de Please take a look at the myCA-project Letzter Update: Tue Jul 01 14:24:28 CEST 2003
Copyright (c) 2002 Reinhard Moosauer IT Beratung, D-84028 Landshut. |
|
||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
|
||||||||||||||
|
|
||||||||||||||