This file and repository needs major work. This is an initial check in with files used in one effort done in an emergency situation. Hope find time to correct it and make it as a tool that can be used to debug
Various tools to debug ssl connection
The container has tools to debug the SSL connection. This includes openssl tools, nodejs, java, keytool, etc
The https call package has calls to create ssl context from a keystore and also from Azure keyvault and call an HTTPS endpoint
The kafka client is a standalone client that can connect to a kafka broker to check the connection. This was the original purpose to create this repository and for that reason this is kept as it is
clustername=kubecluster-aks
az aks get-credentials
--resource-group $resourcegroup
--name $clustername
--subscription $subscription
--admin
openssl s_client -connect serverurl:9092
-cert kafka-consumer-cert-20220902.pfx
-key kafka-consumer-cert-20220902.pfx
-state -debug
openssl s_client
-showcerts
-connect distdbk1.launcher.int.com:9092
< /dev/null
docker build -t busybox-openssl . docker tag busybox-openssl ocadevecr.azurecr.io/oca-commercial_eligibility/busyboxopenssl docker push ocadevecr.azurecr.io/oca-commercial_eligibility/busyboxopenssl
openssl s_client -connect distdbk1.launcher.int.com:9092 -showcerts --verify 5 | awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/{ if(/BEGIN CERTIFICATE/){a++}; out="cert"a".pem"; print >out}'
for cert in .pem; do newname=$(openssl x509 -noout -subject -in $cert | sed -nE 's/.CN ?= ?(.)/\1/; s/[ ,.]//g; s/__//g; s/-/ -/; s/^_//g;p' | tr '[:upper:]' '[:lower:]').pem
openssl s_client -connect distdbk1.launcher.int.com:9092 -CAfile siju/cacerts/infra_ca_g2_et_ou_=ciso_o=_bank_n_v__l=amsterdam_c=_nl.pem -tls1_2 -brief -cert client-cert1.pem -key client-key1.pem
Run the Docker image created above from a repository. Usedd along with docker file from this repository
kubectl run kafkadebug1 -i --tty --rm --image=ocadevecr.azurecr.io/reponame:v20220902.18 --restart=Never -- sh
keytool -importkeystore -srckeystore ../pim-d-sql-kv-pim-d-kafka-consumer-cert-20220902.pfx -srcstoretype PKCS12 -deststoretype PKCS12 -destkeystore keystore.jks -deststorepass changeit -srcstorepass ""
java
-cp sijukafkachecktemp-1.0.0-SNAPSHOT-all.jar
-Djavax.net.debug=all
com.siju.tools.httpscall.ApiClient theUrlToCall keystore.jks
-Djdk.httpclient.HttpClient.log=ssl
-Djdk.httpclient.HttpClient.log=requests
##add a downloaded certificate to the truststore keytool -import -file ca/cert2.pem -alias firstCA -keystore truststore.jks
##convert keystore type to jks keytool -importkeystore -destkeystore client_keystore.jks -deststoretype jks -deststorepass changeit -srckeystore keystore.jks -srcstoretype pkcs12 -srcstorepass changeit
##change keypasswd for key in a keystore keytool -keypasswd -alias 4f6b4855-0f06-4202-8531-cf0c8fbc6611 -keystore client_keystore.jks -new password1
##change password for key and keystore keytool -keypasswd -new password1 -keystore client_keystore.jks -storepass changeit -alias 4f6b4855-0f06-4202-8531-cf0c8fbc6611 -keypass password
kubectl exec --tty --stdin -n service $podname -- /bin/sh
##Service principal create done through the pipeline
first create a service principal. In some orgs through a pipeline. It does not matter where and which RG
sp_password=$(az ad sp create-for-rbac
--name http://xyz-pull
--scope /scope/sdsd/sdsd/sdsds
--role acrpull
--query password
-o tsv)
##get the app Id of the service principal spAppId=$(az ad sp show --id 040590d0-f189-4918-a80d-14cc963ae2f7 --query appId -o tsv)
docker login sanacr1453.azurecr.io --username $spAppId --password FZs8QFH7VFSql3VNzjTJZf-oA3WC2MlH4pUdvI
az acr build -t sample/spring-boot:v1 -r ecrname .
Use service principal to directly push into acr with acr build. This way the docker login is not used
New-AzRoleAssignment -ObjectId 5sdfsdfsdf78868sd7f678678asdas -RoleDefinitionName Contributor
-Scope /subscriptions/39999999999999999999999999999/resourceGroups/resourcegroupname/providers/Microsoft.ContainerRegistry/registries/ecrname
az login --service-principal -u ef7923q94829034877f -p SaeadsasdasdasdasdasdadsasdasdadD --tenant 3aasdasdasdasd-asdasdasdasdasdasd
az acr build --subscription 375555555555555555555555555 -t sample/hello-world:1 -r ecrname .
az role assignment create --assignee 040590d0-f189-4918-a80d-14cc963ae2f7
--role acrPull
--scope $acrregistryid
az role assignment create --assignee 040590d0-f189-4918-a80d-14cc963ae2f7
--role acrPush
--scope $acrregistryid
docker build -t sslconnectiondebugging:v4 . docker tag sslconnectiondebugging:v4 ocadevecr.azurecr.io/sslconnectiondebugging:v4 docker push ocadevecr.azurecr.io/sslconnectiondebugging:v4
kubectl run kafkadebug1 -i --tty --rm --image=ocadevecr.azurecr.io/spring-app:v2 --restart=Never -- sh
kubectl -n service get secrets custom-keystore -o jsonpath --template '{.data}'
cat keystore.txt | base64 --decode > keystore.jks
java -cp .:sslconnectiondebugging-1.0.0-SNAPSHOT-all.jar com.siju.tools.kafkaclient.KafkaClientMain