use of java.security.cert.CertificateException in project robovm by robovm.
the class CertificateExceptionTest method testCertificateException01.
/**
* Test for <code>CertificateException()</code> constructor Assertion:
* constructs CertificateException with no detail message
*/
public void testCertificateException01() {
CertificateException tE = new CertificateException();
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.cert.CertificateException in project robovm by robovm.
the class CertificateExceptionTest method testCertificateException08.
/**
* Test for <code>CertificateException(String, Throwable)</code>
* constructor Assertion: constructs CertificateException when
* <code>cause</code> is not null <code>msg</code> is null
*/
public void testCertificateException08() {
CertificateException tE = new CertificateException(null, tCause);
if (tE.getMessage() != null) {
String toS = tCause.toString();
String getM = tE.getMessage();
assertTrue("getMessage() must should ".concat(toS), (getM.indexOf(toS) != -1));
}
assertNotNull("getCause() must not return null", tE.getCause());
assertEquals("getCause() must return ".concat(tCause.toString()), tE.getCause(), tCause);
}
use of java.security.cert.CertificateException in project Conversations by siacs.
the class IqParser method verification.
public Pair<X509Certificate[], byte[]> verification(final IqPacket packet) {
Element item = getItem(packet);
Element verification = item != null ? item.findChild("verification", AxolotlService.PEP_PREFIX) : null;
Element chain = verification != null ? verification.findChild("chain") : null;
Element signature = verification != null ? verification.findChild("signature") : null;
if (chain != null && signature != null) {
List<Element> certElements = chain.getChildren();
X509Certificate[] certificates = new X509Certificate[certElements.size()];
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
int i = 0;
for (Element cert : certElements) {
certificates[i] = (X509Certificate) certificateFactory.generateCertificate(new ByteArrayInputStream(Base64.decode(cert.getContent(), Base64.DEFAULT)));
++i;
}
return new Pair<>(certificates, Base64.decode(signature.getContent(), Base64.DEFAULT));
} catch (CertificateException e) {
return null;
}
} else {
return null;
}
}
use of java.security.cert.CertificateException in project android-app by spark.
the class WebHelpers method disableTLSforStaging.
private static OkHttpClient disableTLSforStaging() {
log.e("WARNING: TLS DISABLED FOR STAGING!");
OkHttpClient client = new OkHttpClient();
client.setHostnameVerifier(new HostnameVerifier() {
public boolean verify(String hostname, SSLSession session) {
return true;
}
});
try {
SSLContext context = SSLContext.getInstance("TLS");
context.init(null, new X509TrustManager[] { new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
} }, new SecureRandom());
client.setSslSocketFactory(context.getSocketFactory());
} catch (Exception e) {
e.printStackTrace();
}
return client;
}
use of java.security.cert.CertificateException in project platform_frameworks_base by android.
the class OSUManager method readCertsFromDisk.
private static Set<X509Certificate> readCertsFromDisk(String dir) throws CertificateException {
Set<X509Certificate> certs = new HashSet<>();
CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
File caDir = new File(dir);
File[] certFiles = caDir.listFiles();
if (certFiles != null) {
for (File certFile : certFiles) {
try {
try (FileInputStream in = new FileInputStream(certFile)) {
Certificate cert = certFactory.generateCertificate(in);
if (cert instanceof X509Certificate) {
certs.add((X509Certificate) cert);
}
}
} catch (CertificateException | IOException e) {
/* Ignore */
}
}
}
return certs;
}
Aggregations