Created 08-30-2017 06:53 PM
I am trying to configure a brand new Kafka cluster/sandbox with SSL, but I keep getting errors. I apologize for the length of this email, but I've never worked with keystores/certificates before, so while I'm trying to follow the directions here (http://kafka.apache.org/documentation.html#security_ssl), there are a few things I'm doing my best on but don't quite understand. So I'm trying to include below not just exactly what commands I'm running on exactly which nodes, but my interpretation of exactly what they should be doing. I'm also not trying to get client authentication working for the brokers yet - that will be the next step. 🙂
keytool -keystore server.keystore.jks -alias localhost -validity 365 -genkey -keyalg RSA -storepass test1234
openssl req -new -x509 -keyout ca-key -out ca-cert -days 365
keytool -keystore server.truststore.jks -alias CARoot -import -file ca-cert
keytool -keystore client.truststore.jks -alias CARoot -import -file ca-cert
keytool -keystore server.keystore.jks -alias localhost -certreq -file cert-file
scp <username>@<FQDN of broker node>:/tmp/cert-file .
openssl x509 -req -CA ca-cert -CAkey ca-key -in cert-file -out cert-signed -days 365 -CAcreateserial -passin pass:test1234
scp <username>@<FQDN of Edge/CA node>:/tmp/ca-cert . scp <username>@<FQDN of Edge/CA node>:/tmp/cert-signed . keytool -keystore server.keystore.jks -alias CARoot -import -file ca-cert keytool -keystore server.keystore.jks -alias localhost -import -file cert-signed
keytool -keystore server.truststore.jks -alias CARoot -import -file ca-cert
ssl.enabled.protocols=TLSv1.2,TLSv1.1,TLSv1 ssl.endpoint.identification.algorithm=HTTPS ssl.key.password=test1234 ssl.keystore.location=/var/private/ssl/server.keystore.jks ssl.keystore.password=test1234 ssl.truststore.location=/var/private/ssl/server.truststore.jks ssl.truststore.password=test1234 listeners=SSL://<FQDN>:9093 security.inter.broker.protocol=SSL
openssl s_client -debug -connect FQDN:9093 -tls1
<hexdump> -----BEGIN CERTIFICATE----- ... -----END CERTIFICATE----- ... Verify return code: 19 (self signed certificate in certificate chain)
security.protocol=SSL ssl.truststore.location=/var/private/ssl/client.truststore.jks ssl.truststore.password=test1234
kafka-console-consumer.sh --bootstrap-server broker1:9093,broker2:9093,broker3:9093 --topic withssl --consumer.config ssl.properties kafka-console-producer.sh --broker-list broker1:9093,broker2:9093,broker3:9093 --topic withssl --producer.config ssl.properties
[2017-08-30 18:07:58,233] WARN Bootstrap broker broker0:9093 disconnected (org.apache.kafka.clients.NetworkClient) [2017-08-30 18:07:58,544] WARN Bootstrap broker broker1:9093 disconnected (org.apache.kafka.clients.NetworkClient) [2017-08-30 18:07:58,760] WARN Bootstrap broker broker2:9093 disconnected (org.apache.kafka.clients.NetworkClient)
Created 08-31-2017 09:37 PM
It should be like this, in case only the brokers need to authenticate (one-way server side SSL auth) to the clients:
You need:
1. Client side: 1 keystore (client.truststore.jks) containing just the ca_cert you created and was used to sign the broker / server certificates
2. Server side: On each broker 1 keystore (server.keystore.jks) containing both the server specific certificate generated before, ( which should now be signed by the CA) and the certificate of the CA itself.
What is misleading in the Kafka documentation is the first step, where a keystore 'server.keystore.jks' is created in the very first step, only to export the unsigned cert from to actually sign it. This is not the same 'server.keystore.jks' as in 2. above as the it should not contain the unsigned broker cert anymore ! You don't necessarily need a keystore to create a certificate to sign, you can also just create a cert + key, have it signed and then import it into a new keystore.
Also, it makes more sense to me to copy the CA cert onto the brokers then moving it back-and-forth from server -> CA node (to sign) -> back to server (to import into final 'server.keystore.jks')
Hope it makes sense
Created 08-31-2017 09:45 PM
On rereading the Kafka docs, it a about one and the same 'server.keystore.jks' on the brokers after all. The replacement of the initially generated unsigned broker cert by the signed version of that same cert is done by importing the signed cert with the same alias, which effectively overwrites the unsigned cert by the signed one.