Как загрузить сертификат из папки ресурсов (и как их восстановить)? [дубликат] ⇐ JAVA
-
Anonymous
Как загрузить сертификат из папки ресурсов (и как их восстановить)? [дубликат]
Here is my project structure
src └── main ├── java │ └── MainClient.java └── resources └── Certificates ├── clientkeystore.p12 └── clienttruststore.jks I tried following approach of loading certificate
public class MainClient { public static void main(String [] args) { new MainClient(); } public MainClient() { //change the image scaling for the entire application: System.setProperty("sun.java2d.uiScale", "1.0"); System.setProperty("jdk.tls.client.protocols", "TLSv1.3"); System.setProperty("jdk.tls.server.protocols", "TLSv1.3"); System.setProperty("javax.net.ssl.keyStore", "Certificates/clientkeystore.p12"); System.setProperty("javax.net.ssl.keyStorePassword", "password"); System.setProperty("javax.net.ssl.trustStore", "Certificates/clienttruststore.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "password"); } } this worker when Certificates folder was next to my src/ folder ,but when i moved it into resources it didn't work (NOTE: my resources is marked as Resources Root)
Here is my server class
public class MainServer { public static void main(String[] args) { // two lines below are used to set the system properties to enable TLS 1.3 System.setProperty("jdk.tls.client.protocols", "TLSv1.3"); System.setProperty("jdk.tls.server.protocols", "TLSv1.3"); System.setProperty("javax.net.ssl.keyStore", "/home/ja/serverkeystore.p12");// /artifact/... System.setProperty("javax.net.ssl.keyStorePassword", "password"); System.setProperty("javax.net.ssl.trustStore", "/home/ja/servertruststore.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "password"); new GreenServer(4444); } } Reason why i am doing all of this is because i would like to package everything inside a JAR so that certificates can be inside of it.Also how should i regenerate them?My logic on this configuration is based on this article https://www.baeldung.com/java-https-cli ... entication. This is basically two way encryption and i don;t know how should i regenerate these.
Источник: https://stackoverflow.com/questions/780 ... erate-them
Here is my project structure
src └── main ├── java │ └── MainClient.java └── resources └── Certificates ├── clientkeystore.p12 └── clienttruststore.jks I tried following approach of loading certificate
public class MainClient { public static void main(String [] args) { new MainClient(); } public MainClient() { //change the image scaling for the entire application: System.setProperty("sun.java2d.uiScale", "1.0"); System.setProperty("jdk.tls.client.protocols", "TLSv1.3"); System.setProperty("jdk.tls.server.protocols", "TLSv1.3"); System.setProperty("javax.net.ssl.keyStore", "Certificates/clientkeystore.p12"); System.setProperty("javax.net.ssl.keyStorePassword", "password"); System.setProperty("javax.net.ssl.trustStore", "Certificates/clienttruststore.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "password"); } } this worker when Certificates folder was next to my src/ folder ,but when i moved it into resources it didn't work (NOTE: my resources is marked as Resources Root)
Here is my server class
public class MainServer { public static void main(String[] args) { // two lines below are used to set the system properties to enable TLS 1.3 System.setProperty("jdk.tls.client.protocols", "TLSv1.3"); System.setProperty("jdk.tls.server.protocols", "TLSv1.3"); System.setProperty("javax.net.ssl.keyStore", "/home/ja/serverkeystore.p12");// /artifact/... System.setProperty("javax.net.ssl.keyStorePassword", "password"); System.setProperty("javax.net.ssl.trustStore", "/home/ja/servertruststore.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "password"); new GreenServer(4444); } } Reason why i am doing all of this is because i would like to package everything inside a JAR so that certificates can be inside of it.Also how should i regenerate them?My logic on this configuration is based on this article https://www.baeldung.com/java-https-cli ... entication. This is basically two way encryption and i don;t know how should i regenerate these.
Источник: https://stackoverflow.com/questions/780 ... erate-them
Мобильная версия