javax.net.ssl.HttpsURLConnection.getLocalCertificates()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中javax.net.ssl.HttpsURLConnection.getLocalCertificates()方法的一些代码示例,展示了HttpsURLConnection.getLocalCertificates()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpsURLConnection.getLocalCertificates()方法的具体详情如下:
包路径:javax.net.ssl.HttpsURLConnection
类名称:HttpsURLConnection
方法名:getLocalCertificates

HttpsURLConnection.getLocalCertificates介绍

[英]Returns the list of local certificates used during the handshake. These certificates were sent to the peer.
[中]返回握手期间使用的本地证书的列表。这些证书已发送给对等方。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Returns the {@code Principal} used to identify the local host during the handshake.
 *
 * @return the {@code Principal} used to identify the local host during the handshake, or
 *         {@code null} if none was used.
 * @throws IllegalStateException
 *             if no connection has been established yet.
 */
public Principal getLocalPrincipal() {
  Certificate[] certs = getLocalCertificates();
  if (certs == null || certs.length == 0 || (!(certs[0] instanceof X509Certificate))) {
    return null;
  }
  return ((X509Certificate) certs[0]).getSubjectX500Principal();
}

代码示例来源:origin: square/okhttp

Certificate[] localCertificates = httpsUrlConnection.getLocalCertificates();

代码示例来源:origin: org.apache.cxf/cxf-rt-transports-http

HttpsURLConnection conn = (HttpsURLConnection) connection;
enabledCipherSuite = conn.getCipherSuite();
localCertificates = conn.getLocalCertificates();
localPrincipal = conn.getLocalPrincipal();
serverCertificates = conn.getServerCertificates();

代码示例来源:origin: MobiVM/robovm

/**
 * Returns the {@code Principal} used to identify the local host during the handshake.
 *
 * @return the {@code Principal} used to identify the local host during the handshake, or
 *         {@code null} if none was used.
 * @throws IllegalStateException
 *             if no connection has been established yet.
 */
public Principal getLocalPrincipal() {
  Certificate[] certs = getLocalCertificates();
  if (certs == null || certs.length == 0 || (!(certs[0] instanceof X509Certificate))) {
    return null;
  }
  return ((X509Certificate) certs[0]).getSubjectX500Principal();
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns the {@code Principal} used to identify the local host during the handshake.
 *
 * @return the {@code Principal} used to identify the local host during the handshake, or
 *         {@code null} if none was used.
 * @throws IllegalStateException
 *             if no connection has been established yet.
 */
public Principal getLocalPrincipal() {
  Certificate[] certs = getLocalCertificates();
  if (certs == null || certs.length == 0 || (!(certs[0] instanceof X509Certificate))) {
    return null;
  }
  return ((X509Certificate) certs[0]).getSubjectX500Principal();
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Returns the {@code Principal} used to identify the local host during the handshake.
 *
 * @return the {@code Principal} used to identify the local host during the handshake, or
 *         {@code null} if none was used.
 * @throws IllegalStateException
 *             if no connection has been established yet.
 */
public Principal getLocalPrincipal() {
  Certificate[] certs = getLocalCertificates();
  if (certs == null || certs.length == 0 || (!(certs[0] instanceof X509Certificate))) {
    return null;
  }
  return ((X509Certificate) certs[0]).getSubjectX500Principal();
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns the {@code Principal} used to identify the local host during the handshake.
 *
 * @return the {@code Principal} used to identify the local host during the handshake, or
 *         {@code null} if none was used.
 * @throws IllegalStateException
 *             if no connection has been established yet.
 */
public Principal getLocalPrincipal() {
  Certificate[] certs = getLocalCertificates();
  if (certs == null || certs.length == 0 || (!(certs[0] instanceof X509Certificate))) {
    return null;
  }
  return ((X509Certificate) certs[0]).getSubjectX500Principal();
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Returns the {@code Principal} used to identify the local host during the handshake.
 *
 * @return the {@code Principal} used to identify the local host during the handshake, or
 *         {@code null} if none was used.
 * @throws IllegalStateException
 *             if no connection has been established yet.
 */
public Principal getLocalPrincipal() {
  Certificate[] certs = getLocalCertificates();
  if (certs == null || certs.length == 0 || (!(certs[0] instanceof X509Certificate))) {
    return null;
  }
  return ((X509Certificate) certs[0]).getSubjectX500Principal();
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Returns the {@code Principal} used to identify the local host during the handshake.
 *
 * @return the {@code Principal} used to identify the local host during the handshake, or
 *         {@code null} if none was used.
 * @throws IllegalStateException
 *             if no connection has been established yet.
 */
public Principal getLocalPrincipal() {
  Certificate[] certs = getLocalCertificates();
  if (certs == null || certs.length == 0 || (!(certs[0] instanceof X509Certificate))) {
    return null;
  }
  return ((X509Certificate) certs[0]).getSubjectX500Principal();
}

代码示例来源: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: apache/cxf

HttpsURLConnection conn = (HttpsURLConnection) connection;
enabledCipherSuite = conn.getCipherSuite();
localCertificates = conn.getLocalCertificates();
localPrincipal = conn.getLocalPrincipal();
serverCertificates = conn.getServerCertificates();

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

HttpsURLConnection conn = (HttpsURLConnection) connection;
enabledCipherSuite = conn.getCipherSuite();
localCertificates  = conn.getLocalCertificates();
localPrincipal     = conn.getLocalPrincipal();
serverCertificates = conn.getServerCertificates();

代码示例来源: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: com.squareup.okhttp3/okhttp-android-support

Certificate[] localCertificates = httpsUrlConnection.getLocalCertificates();

相关文章

HttpsURLConnection类方法