本文整理了Java中javax.net.ssl.HttpsURLConnection.getCipherSuite()
方法的一些代码示例,展示了HttpsURLConnection.getCipherSuite()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpsURLConnection.getCipherSuite()
方法的具体详情如下:
包路径:javax.net.ssl.HttpsURLConnection
类名称:HttpsURLConnection
方法名:getCipherSuite
[英]Returns the name of the cipher suite negotiated during the SSL handshake.
[中]返回SSL握手期间协商的密码套件的名称。
代码示例来源:origin: stackoverflow.com
if (conn instanceof HttpsURLConnection) {
HttpsURLConnection secured = (HttpsURLConnection) conn;
String cipher = secured.getCipherSuite();
}
代码示例来源:origin: square/okhttp
String cipherSuiteString = httpsUrlConnection.getCipherSuite();
CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
Handshake handshake = Handshake.get(TlsVersion.SSL_3_0, cipherSuite,
代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http
if (connection instanceof HttpsURLConnection) {
HttpsURLConnection conn = (HttpsURLConnection) connection;
enabledCipherSuite = conn.getCipherSuite();
localCertificates = conn.getLocalCertificates();
localPrincipal = conn.getLocalPrincipal();
代码示例来源:origin: stackoverflow.com
Security.addProvider(new BouncyCastleProvider());
SSLContext sslContext = SSLContext.getInstance("TLS");
TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init((KeyStore)null); //this is where you would add the truststore
KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
KeyStore keyStore = KeyStore.getInstance("PKCS12"); //spongyCastle library
keyStore.load(new FileInputStream("D:\\Documents\\VISA Direct Api\\cabcentralcert.p12"), "cabcentral".toCharArray()); //inputStream to PKCS12
keyManagerFactory.init(keyStore, "cabcentral".toCharArray());
//TrustManager[] trustManagers = trustManagerFactory.getTrustManagers();
TrustManager[] trustAllCertManagers = { new X509TrustManager() { // this is vulnerable to MITM attack
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
}};
sslContext.init(keyManagerFactory.getKeyManagers(), trustAllCertManagers, new SecureRandom());
URL url = new URL(strUrl);
HttpsURLConnection httpsUrlConnection = (HttpsURLConnection) url.openConnection();
httpsUrlConnection.setSSLSocketFactory(sslContext.getSocketFactory());
System.out.println("Response Code : " + httpsUrlConnection.getResponseCode());
System.out.println("Cipher Suite : " + httpsUrlConnection.getCipherSuite());
代码示例来源:origin: org.symphonyoss.symphony/jcurl
private void processResponseCertificates(HttpURLConnection con, Response response) throws SSLPeerUnverifiedException {
if (con instanceof HttpsURLConnection) {
try {
HttpsURLConnection secureConn = (HttpsURLConnection) con;
response.cipherSuite = secureConn.getCipherSuite();
response.serverCertificates = secureConn.getServerCertificates();
response.clientCertificates = secureConn.getLocalCertificates();
} catch (IllegalStateException e) {
// If the response is not a 200, getting response certificates will fail with the (misleading) message
// "connection not yet open". Ignore this.
}
}
}
代码示例来源:origin: net.exogeni.orca.core/shirako
System.out.println("Cipher Suite : " + con.getCipherSuite());
System.out.println("\n");
代码示例来源:origin: apache/cxf
if (connection instanceof HttpsURLConnection) {
HttpsURLConnection conn = (HttpsURLConnection) connection;
enabledCipherSuite = conn.getCipherSuite();
localCertificates = conn.getLocalCertificates();
localPrincipal = conn.getLocalPrincipal();
代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs
if (connection instanceof HttpsURLConnection) {
HttpsURLConnection conn = (HttpsURLConnection) connection;
enabledCipherSuite = conn.getCipherSuite();
localCertificates = conn.getLocalCertificates();
localPrincipal = conn.getLocalPrincipal();
代码示例来源:origin: org.microemu/microemu-javase
public SecurityInfo getSecurityInfo() throws IOException {
if (securityInfo == null) {
if (cn == null) {
throw new IOException();
}
if (!connected) {
cn.connect();
connected = true;
}
HttpsURLConnection https = (HttpsURLConnection) cn;
Certificate[] certs = https.getServerCertificates();
if (certs.length == 0) {
throw new IOException();
}
securityInfo = new SecurityInfoImpl(
https.getCipherSuite(),
sslContext.getProtocol(),
new CertificateImpl((X509Certificate) certs[0]));
}
return securityInfo;
}
代码示例来源:origin: stackoverflow.com
System.out.println("Cipher Suite : " + con.getCipherSuite());
System.out.println("\n");
代码示例来源:origin: candrews/HttpResponseCache
public Entry(URI uri, RawHeaders varyHeaders, HttpURLConnection httpConnection) {
this.uri = uri.toString();
this.varyHeaders = varyHeaders;
this.requestMethod = httpConnection.getRequestMethod();
this.responseHeaders = RawHeaders.fromMultimap(httpConnection.getHeaderFields());
if (isHttps()) {
HttpsURLConnection httpsConnection = (HttpsURLConnection) httpConnection;
cipherSuite = httpsConnection.getCipherSuite();
Certificate[] peerCertificatesNonFinal = null;
try {
peerCertificatesNonFinal = httpsConnection.getServerCertificates();
} catch (SSLPeerUnverifiedException ignored) {
}
peerCertificates = peerCertificatesNonFinal;
localCertificates = httpsConnection.getLocalCertificates();
} else {
cipherSuite = null;
peerCertificates = null;
localCertificates = null;
}
}
代码示例来源:origin: guardianproject/NetCipher
assertEquals(200, connection.getResponseCode());
assertEquals("text/html", connection.getContentType().split(";")[0]);
System.out.println(host + " " + connection.getCipherSuite());
assertTrue(connection.getCipherSuite().startsWith("TLS"));
connection.disconnect();
代码示例来源:origin: guardianproject/NetCipher
assertEquals(200, connection.getResponseCode());
assertEquals("text/html", connection.getContentType().split(";")[0]);
System.out.println(host + " " + connection.getCipherSuite());
assertTrue(connection.getCipherSuite().startsWith("TLS"));
connection.disconnect();
代码示例来源:origin: guardianproject/NetCipher
assertEquals(200, connection.getResponseCode());
assertEquals("text/html", connection.getContentType().split(";")[0]);
System.out.println(host + " " + connection.getCipherSuite());
assertTrue(connection.getCipherSuite().startsWith("TLS"));
connection.disconnect();
代码示例来源:origin: com.squareup.okhttp3/okhttp-android-support
String cipherSuiteString = httpsUrlConnection.getCipherSuite();
CipherSuite cipherSuite = CipherSuite.forJavaName(cipherSuiteString);
Handshake handshake = Handshake.get(TlsVersion.SSL_3_0, cipherSuite,
内容来源于网络,如有侵权,请联系作者删除!