本文整理汇总了Java中java.security.cert.CertificateException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java CertificateException.printStackTrace方法的具体用法?Java CertificateException.printStackTrace怎么用?Java CertificateException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.security.cert.CertificateException
的用法示例。
在下文中一共展示了CertificateException.printStackTrace方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: v
import java.security.cert.CertificateException; //导入方法依赖的package包/类
public static String v(Context context) {
PackageInfo packageInfo;
String str = null;
try {
packageInfo = context.getPackageManager().getPackageInfo(u(context), 64);
} catch (NameNotFoundException e) {
e.printStackTrace();
Object obj = str;
}
InputStream byteArrayInputStream = new ByteArrayInputStream(packageInfo.signatures[0].toByteArray());
try {
CertificateFactory instance = CertificateFactory.getInstance("X509");
} catch (CertificateException e2) {
e2.printStackTrace();
obj = str;
}
try {
X509Certificate x509Certificate = (X509Certificate) instance.generateCertificate(byteArrayInputStream);
} catch (CertificateException e22) {
e22.printStackTrace();
obj = str;
}
try {
str = a(MessageDigest.getInstance(CommonUtils.MD5_INSTANCE).digest(x509Certificate.getEncoded()));
} catch (NoSuchAlgorithmException e3) {
e3.printStackTrace();
} catch (CertificateEncodingException e4) {
e4.printStackTrace();
}
return str;
}
示例2: w
import java.security.cert.CertificateException; //导入方法依赖的package包/类
public static String w(Context context) {
PackageInfo packageInfo;
String str = null;
try {
packageInfo = context.getPackageManager().getPackageInfo(v(context), 64);
} catch (NameNotFoundException e) {
e.printStackTrace();
Object obj = str;
}
InputStream byteArrayInputStream = new ByteArrayInputStream(packageInfo.signatures[0].toByteArray());
try {
CertificateFactory instance = CertificateFactory.getInstance("X509");
} catch (CertificateException e2) {
e2.printStackTrace();
obj = str;
}
try {
X509Certificate x509Certificate = (X509Certificate) instance.generateCertificate(byteArrayInputStream);
} catch (CertificateException e22) {
e22.printStackTrace();
obj = str;
}
try {
str = a(MessageDigest.getInstance(Coder.KEY_MD5).digest(x509Certificate.getEncoded()));
} catch (NoSuchAlgorithmException e3) {
e3.printStackTrace();
} catch (CertificateEncodingException e4) {
e4.printStackTrace();
}
return str;
}
示例3: getKeystoreOfCA
import java.security.cert.CertificateException; //导入方法依赖的package包/类
public static KeyStore getKeystoreOfCA(InputStream cert) {
CertificateException e1;
KeyStore keyStore;
Throwable th;
InputStream caInput = null;
Certificate ca = null;
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
InputStream caInput2 = new BufferedInputStream(cert);
try {
ca = cf.generateCertificate(caInput2);
if (caInput2 != null) {
try {
caInput2.close();
} catch (IOException e) {
e.printStackTrace();
caInput = caInput2;
}
}
caInput = caInput2;
} catch (CertificateException e2) {
e1 = e2;
caInput = caInput2;
try {
e1.printStackTrace();
if (caInput != null) {
try {
caInput.close();
} catch (IOException e3) {
e3.printStackTrace();
}
}
keyStore = null;
keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
keyStore.setCertificateEntry("ca", ca);
return keyStore;
} catch (Throwable th2) {
th = th2;
if (caInput != null) {
try {
caInput.close();
} catch (IOException e32) {
e32.printStackTrace();
}
}
throw th;
}
} catch (Throwable th3) {
th = th3;
caInput = caInput2;
if (caInput != null) {
caInput.close();
}
throw th;
}
} catch (CertificateException e4) {
e1 = e4;
e1.printStackTrace();
if (caInput != null) {
caInput.close();
}
keyStore = null;
keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
keyStore.setCertificateEntry("ca", ca);
return keyStore;
}
keyStore = null;
try {
keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
keyStore.setCertificateEntry("ca", ca);
return keyStore;
} catch (Exception e5) {
e5.printStackTrace();
return keyStore;
}
}
示例4: main
import java.security.cert.CertificateException; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// The two sections below are identical, a self-signed cert generated
// for a fake principal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wdjVH++mGvwU/m/Ju\n" +
"OpaaWOEFRHgCMe5fZ2xE0pWPcmKkPicc85SKHguYTMCc9D0XbTbkoBIEAeQ4nr2GmXuEQ5tYaO/O\n" +
"PYXjk9EfGhikHlnKgC6jITAfMB0GA1UdDgQWBBTtv4rKVwXtXJpyZWlswQL4MAKkazALBgcqhkjO\n" +
"OAQDBQADMAAwLQIVAIU4pnnUcMjh2CUvh/B0PSZZTHHvAhQVMhAdwNHOGPSL6sCL19q6UjoN9w==\n" +
"-----END CERTIFICATE-----\n";
try {
CertificateFactory.getInstance("X509").generateCertificates(
new ByteArrayInputStream(cert.getBytes()));
throw new Exception("Fail. certificate generation should fail");
} catch (CertificateException ce) {
ce.printStackTrace();
// This is the correct result
}
}