12월, 2015의 게시물 표시

EJBCA Web Service

import java.net.MalformedURLException; import java.net.URL; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.cert.X509Certificate; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; import javax.xml.namespace.QName; import org.ejbca.core.protocol.ws.client.gen.EjbcaWS; import org.ejbca.core.protocol.ws.client.gen.EjbcaWSService; public class Program { public static void main(String[] args) { EjbcaWS ejbcaws = null;  // A single instance is enough //CryptoProviderTools.installBCProvider(); // TODO Auto-generated method stub         System.setProperty ("javax.net.ssl.trustStore", "c:\\temp\\truststore.jks");         System.setProperty ("javax.net.ssl.trustStorePassword", "changeit"); ...

P12 <--> JKS

keytool -importkeystore -srckeystore superadmin.p12 -srcstoretype PKCS12 -deststoretype JKS -destkeystore superadmin.jks http://blog.ejbca.org/2008/02/converting-keystores-between-jks-and.html

Key generation

package cccc; import java.math.BigInteger; import java.security.InvalidAlgorithmParameterException; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.PrivateKey; import java.security.PublicKey; import java.security.SecureRandom; import java.security.Security; //import java.util.Base64; import org.apache.commons.codec.binary.Base64; import org.bouncycastle.asn1.pkcs.PrivateKeyInfo; import org.bouncycastle.crypto.util.PrivateKeyInfoFactory; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.math.ec.ECCurve; //import ; import org.bouncycastle.util.encoders.Hex; import org.bouncycastle.jce.spec.ECParameterSpec; public class vvv { public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException { Security.addProvider(new BouncyC...