java ile appden ssl olan hostlara qoshulma uchun sertifikat meselesi

1 ci usul JVM in cacertine elave etmek

Windows: 

keytool -import -alias cert_alias -file cert.cer -keystore "C:\Program Files\Java\jdk-11.0.9\lib\security\cacerts


kodu ise changeit verilir , kod shertidir bashqa sheyde vermek olar

lazim olan sertifikati  uygun saydan yukleyirik sora onun kompdaki pathda bu komandi verilir , meselen download foldere dushubse ora gedib yuxaridaki commandi run edirik cmd de


Mac:

import cert into jvm 17(other versions same as well) 

1.  cd /Library/Java/JavaVirtualMachines/jdk-17.0.5.jdk/Contents/Home/lib/security

 2. sudo keytool -import -file ~/Documents/certs/fusion.cer -keystore /Library/Java/JavaVirtualMachines/jdk-17.0.5.jdk/Contents/Home/lib/security/cacerts -alias "fusion"


2 ci usul. appin folderinde trustStore yaradib, jvmi override etmek

Yuxaridaki numunelerde serverin certifikati jvm in cacertine elave olunur. Amma jvmin default cacertini override edib , appin ichinde cacert yaratmaq mumkundur:


keytool -import -trustcacerts -file certs/fusion.cer -keypass password -storepass password -keystore clienttruststore.jks

bu komanda vasitesile appin directorysinde clienttruststore.jks file yaranacaq ve o fusion.cer i taniyacaq

Daha sonra app run olarken

System.setProperty("javax.net.ssl.trustStore", "clienttruststore.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "password");

bu parameterleri set etsek ssl qoshulmada problem olmayacaq.


Comments

Popular posts from this blog

Installation instructions for some programs on linux ubuntu

Hibernate and Application Performance

Java Date and Time examples