Web Services with Security
1) Generate self-sign certificate.
2) Assign certificate to Webservice and change protocol type to https while publishing webservice.3) Import certificate into keytool using keytool of java.
4) Write a java client based on generated wsdl.
Command to import certificate into keytool
C:\>keytool -import -trustcacerts -alias HTTPSCertificateName -file D:\Projects\HTTPSCertificateName .cer -keystore "C:\Program Files\Java\jdk1.5.0_11\jre\lib\security\cacerts"
password: changeit
Note:
(1) About command will import certificate into C:\Program Files\Java\jdk1.5.0_11\jre\lib\security\cacerts.
(2) Make sure your C:\Program Files\Java\jdk1.5.0_11\jre\lib\security\cacerts file should update with latest date and time if it is successfuly imported.
System Properties to set in Java code
System.setProperty("javax.net.ssl.trustStore","C:\\Program Files\\Java\\jdk1.5.0_11\\jre\\lib\\security\\cacerts");
System.setProperty("javax.net.ssl.trustStorePassword","changeit");
Note: changeit is the default password for java keytool.
No comments:
Post a Comment