在Security編程中
DER
PEM
PKCS#
PKCS#
PKCS#
PKCS#
pfx/p
p
p
p
其中
X
int iKeySize = X
System
System
提取了他所需要的信息
package org
import java
import java
import java
import java
import java
import java
import java
import java
import java
import java
import java
import java
import org
public class LoadKeyFromPKCS
public static void main(String[] args) {
try {
// Open an input stream on the keystore file
String pfxFileName =
String pfxPassword =
File fPkcs
if (pfxFileName != null ) {
// Open the file
fPkcs
}
FileInputStream fis = new FileInputStream(fPkcs
// Create a keystore object
KeyStore keyStore = null ;
try
{
// Need BC provider for PKCS #
if (Security
{
throw new Exception(
}
keyStore = KeyStore
}
catch (KeyStoreException ex)
{
throw new Exception(
}
catch (NoSuchProviderException ex)
{
throw new Exception(
}
try
{
// Load the file into the keystore
keyStore
}
catch (CertificateException ex)
{
throw new Exception(
}
catch (NoSuchAlgorithmException ex)
{
throw new Exception(
}
catch (FileNotFoundException ex)
{
throw new Exception(
}
catch (IOException ex)
{
throw new Exception(
}
// 獲取我的證書鏈的中keyEntry的別名
Certificate[] certs = keyStore
X
if (x
{
return ;
}
x
X
int iKeySize = X
System
System
} catch (Exception e) {
e
}
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26970.html