本文整理了Java中okhttp3.mockwebserver.MockWebServer.useHttps()
方法的一些代码示例,展示了MockWebServer.useHttps()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MockWebServer.useHttps()
方法的具体详情如下:
包路径:okhttp3.mockwebserver.MockWebServer
类名称:MockWebServer
方法名:useHttps
[英]Serve requests with HTTPS rather than otherwise.
[中]
代码示例来源:origin: square/okhttp
public void run() throws IOException {
MockWebServer server = new MockWebServer();
server.useHttps(sslContext.getSocketFactory(), false);
server.setDispatcher(this);
server.start(port);
}
代码示例来源:origin: square/okhttp
public void run() throws Exception {
String localhost = InetAddress.getByName("localhost").getCanonicalHostName();
HeldCertificate localhostCertificate = new HeldCertificate.Builder()
.addSubjectAlternativeName(localhost)
.build();
HandshakeCertificates serverCertificates = new HandshakeCertificates.Builder()
.heldCertificate(localhostCertificate)
.build();
MockWebServer server = new MockWebServer();
server.useHttps(serverCertificates.sslSocketFactory(), false);
server.enqueue(new MockResponse());
HandshakeCertificates clientCertificates = new HandshakeCertificates.Builder()
.addTrustedCertificate(localhostCertificate.certificate())
.build();
OkHttpClient client = new OkHttpClient.Builder()
.sslSocketFactory(clientCertificates.sslSocketFactory(), clientCertificates.trustManager())
.build();
Call call = client.newCall(new Request.Builder()
.url(server.url("/"))
.build());
Response response = call.execute();
System.out.println(response.handshake().tlsVersion());
}
代码示例来源:origin: fabric8io/mockwebserver
private void startInternal() {
if (initialized.compareAndSet(false, true)) {
if (useHttps) {
server.useHttps(MockSSLContextFactory.create().getSocketFactory(), false);
}
onStart();
}
}
代码示例来源:origin: stackoverflow.com
MockWebServer serverForHttps = new MockWebServer();
serverForHttps .useHttps(SslContextBuilder.localhost().getSocketFactory(), false);
serverForHttps .start()
代码示例来源:origin: xjdr/xio
public static MockWebServer getSslMockWebServer(KeyManager[] keyManagers) throws Exception {
MockWebServer server = new MockWebServer();
server.useHttps(
OkHttpUnsafe.getUnsafeSSLSocketFactory(keyManagers, unsafeTrustManager()), false);
return server;
}
}
代码示例来源:origin: cloudant/java-cloudant
@BeforeEach
public void beforeEach() {
server = mockWebServerExt.get();
server.useHttps(MockWebServerResources.getSSLSocketFactory(), false);
}
代码示例来源:origin: cloudant/java-cloudant
/**
* Enables https on the mock web server receiving our requests if useHttpsServer is true.
*
* @throws Exception
*/
@BeforeEach
public void setupMockServerSSLIfNeeded(final boolean okUsable,
final boolean useSecureProxy,
final boolean useHttpsServer,
final boolean useProxyAuth) throws Exception {
server = serverExt.get();
if (useHttpsServer) {
server.useHttps(MockWebServerResources.getSSLSocketFactory(), false);
}
}
代码示例来源:origin: cloudant/java-cloudant
@BeforeEach
public void beforeEach() {
server = mockWebServerExt.get();
server.useHttps(MockWebServerResources.getSSLSocketFactory(), false);
mockServerHostPort = String.format("%s:%s/", server.getHostName(), server.getPort());
//setup mock IAM server
mockIamServer = mockIamServerExt.get();
iamSystemPropertyMock.setMockIamTokenEndpointUrl(mockIamServer.url(iamTokenEndpoint)
.toString());
}
内容来源于网络,如有侵权,请联系作者删除!