2016-05-31 2 views
0

ich dieses Tutorial folgte meinem Kater ssl zu setzen: http://www.mkyong.com/tomcat/how-to-configure-tomcat-to-support-ssl-or-https/send exportierte Zertifikat von Schlüsselspeicher mit curl

ich die Schlüsselspeicherdatei mystore2.jks statt mkyongkeystore benannt. Dann zum Keystore hinzugefügt ich ein anderes Zertifikat wie folgt.

keytool -genkey -alias testhim -keyalg RSA -keystore mystore2.jks 

exportiert es dann wie folgt aus:

keytool -export -alias testhim -file forcurl.crt -keystore mystore2.jks 

jetzt will ich mein Kater https testen, mit 'forcurl.crt'

curl https://localhost:8443 --cert forcurl.crt 

curl: (58) unable to use client certificate (no key found or wrong pass phrase?) 

wie kann ich das Passwort übergeben? Sollte das exportierte Zertifikat eine CRT-Datei sein? Ist die Methode korrekt, wird ein Zertifikat aus dem Keystore exportiert, auf den tomcat zeigt, und dieses Zertifikat dann mit curl verwendet, um die tomcat URL zu treffen?

forcurl.crt sieht so aus, wie diese Codierung heißt. Nicht PEM sicher:

3082 036d 3082 0255 a003 0201 0202 0433 
c4ed 0830 0d06 092a 8648 86f7 0d01 010b 
0500 3067 310b 3009 0603 5504 0613 0264 
6b31 1030 0e06 0355 0408 1307 7465 7374 
6869 6d31 1030 0e06 0355 0407 1307 7465 
7374 6869 6d31 1030 0e06 0355 040a 1307 
7465 7374 6869 6d31 1030 0e06 0355 040b 
1307 7465 7374 6869 6d31 1030 0e06 0355 
0403 1307 7465 7374 6869 6d30 1e17 0d31 
... 

konnte ich die URL mit dem folgenden Befehl treffen und erhalten Antwort: curl https://localhost:8443 --insecure

Ich möchte niemand auf die URL zugreifen, da es REST sein API. Um auf die URL zuzugreifen, muss man sein Zertifikat vorlegen.

Ich habe den tomcat> server.xml https Connector auf true clientAuth = "true" geändert.

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" 
       maxThreads="150" SSLEnabled="true" scheme="https" secure="true" 
       clientAuth="true" sslProtocol="TLS" keystoreFile="/home/nowshad/dump/mystore2.jks" 
     keystorePass="123456"/> 

Dann verwendet:

curl https://localhost:8443 --insecure -v 

Dies ist die Ausgabe:

[email protected]:~$ curl https://localhost:8443 --insecure -v 
* Rebuilt URL to: https://localhost:8443/ 
* Hostname was NOT found in DNS cache 
* Trying 127.0.0.1... 
* Connected to localhost (127.0.0.1) port 8443 (#0) 
* successfully set certificate verify locations: 
* CAfile: none 
    CApath: /etc/ssl/certs 
* SSLv3, TLS handshake, Client hello (1): 
* SSLv3, TLS handshake, Server hello (2): 
* SSLv3, TLS handshake, CERT (11): 
* SSLv3, TLS handshake, Server key exchange (12): 
* SSLv3, TLS handshake, Request CERT (13): 
* SSLv3, TLS handshake, Server finished (14): 
* SSLv3, TLS handshake, CERT (11): 
* SSLv3, TLS handshake, Client key exchange (16): 
* SSLv3, TLS change cipher, Client hello (1): 
* SSLv3, TLS handshake, Finished (20): 
* Unknown SSL protocol error in connection to localhost:8443 
* Closing connection 0 
curl: (35) Unknown SSL protocol error in connection to localhost:8443 

Antwort

0

Wenn es ein selbst signiertes Zertifikat, curl https://localhost:8443 --insecure sollte Test ausreichend. Wenn es von einer Zertifizierungsstelle signiert ist, rufen Sie es einfach normal curl https://localhost:8443.

Der Client muss das Zertifikat nicht haben, vor allem nicht den Schlüssel, um zu kommunizieren. Der Server bietet das Zertifikat an, wenn der Client eine Verbindung herstellt.

Alles, was der Client benötigt, ist das CA-Zertifikat, das das Zertifikat signiert hat, damit es überprüfen kann, ob es gültig ist oder nicht.

Fügen Sie -v hinzu, um eine ausführliche Ausgabe zu cURL hinzuzufügen.

+0

Danke curl https: // localhost: 8443 --insecure gearbeitet. Ich wollte den Zugang für alle sperren, nur das Präsentieren eines Zertifikats macht ihn zum legitimen Benutzer. – ghost