DevShivmohan / Learning-everything

Learning for developer only
0 stars 1 forks source link

Apache Kafka, SSL and TLS configuration in grpc spring boot #36

Open DevShivmohan opened 10 months ago

DevShivmohan commented 10 months ago

Create openssl certificate for localhost

//Generate CA's private key openssl genrsa -des3 -out ca.key.pem 2048

//create CA's self-signed certificate openssl req -x509 -new -nodes -key ca.key.pem -sha256 -days 365 -out localhost.cert.pem

//create private key for server openssl genrsa -out localhost.key 2048

//create certificate signing request (CSR) openssl req -new -key localhost.key -out localhost.csr

//Use CA's private key to sign web server's CSR and get back the signed certificate openssl x509 -req -in localhost.csr -CA localhost.cert.pem -CAkey ca.key.pem -CAcreateserial -out localhost.crt -days 365

//convert server private key in PKCS8 standard(gRPc expects) openssl pkcs8 -topk8 -nocrypt -in localhost.key -out localhost.pem

Demo with live screenshots

image image

DevShivmohan commented 10 months ago

Spring boot grpc configuration with TLS security

DevShivmohan commented 10 months ago

Install Apache Kafka and configure it in Ubuntu

DevShivmohan commented 10 months ago

Example steps to implement CA, truststore and keystore for apache kafka/zookeeper SSL/TLS security

If there is occur any erros during run apache-kafka then try to delete all logs of zookeeper and kafka logs like below screenshot image.

DevShivmohan commented 10 months ago

In Spring-boot configuration with SSL/TLS apache kafka

ssl.protocol = TLS spring.kafka.bootstrap-servers=localhost:9093 spring.kafka.properties.security.protocol=TLS spring.kafka.properties.ssl.truststore.location=file:/home/kafka/kafka_2.12-3.5.1/ssl/kafka.zookeeper.truststore.jks spring.kafka.properties.ssl.truststore.password=123456 spring.kafka.properties.ssl.keystore.location=file:/home/kafka/kafka_2.12-3.5.1/ssl/kafka.zookeeper.keystore.jks spring.kafka.properties.ssl.keystore.password=123456 spring.kafka.properties.ssl.key.password=123456

spring.kafka.producer.bootstrap-servers=localhost:9093 spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer spring.kafka.consumer.bootstrap-servers=localhost:9093 spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer