當前位置: 首頁>>代碼示例>>Java>>正文


Java SelfSignedCertificate類代碼示例

本文整理匯總了Java中io.vertx.core.net.SelfSignedCertificate的典型用法代碼示例。如果您正苦於以下問題:Java SelfSignedCertificate類的具體用法?Java SelfSignedCertificate怎麽用?Java SelfSignedCertificate使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SelfSignedCertificate類屬於io.vertx.core.net包,在下文中一共展示了SelfSignedCertificate類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testRecordCreation

import io.vertx.core.net.SelfSignedCertificate; //導入依賴的package包/類
@Test
public void testRecordCreation(TestContext testContext) {
  Record record = HttpEndpoint.createRecord("some-name", "123.456.789.111", 80, null);
  assertThat(record.getLocation().getString(Record.ENDPOINT)).isEqualTo("http://123.456.789.111:80/");

  record = HttpEndpoint.createRecord("some-name", "123.456.789.111", 80, "foo");
  assertThat(record.getLocation().getString(Record.ENDPOINT)).isEqualTo("http://123.456.789.111:80/foo");

  record = HttpEndpoint.createRecord("some-name", "123.456.789.111", 80, "foo", new JsonObject().put("language", "en"));
  assertThat(record.getLocation().getString(Record.ENDPOINT)).isEqualTo("http://123.456.789.111:80/foo");
  assertThat(record.getMetadata().getString("language")).isEqualTo("en");

  record = HttpEndpoint.createRecord("some-name", "acme.org");
  assertThat(record.getLocation().getString(Record.ENDPOINT)).isEqualTo("http://acme.org:80/");

  SelfSignedCertificate selfSignedCertificate = SelfSignedCertificate.create();
  vertx.createHttpServer(new HttpServerOptions()
    .setHost("127.0.0.1")
    .setSsl(true)
    .setKeyCertOptions(selfSignedCertificate.keyCertOptions())
  ).requestHandler(request -> {
    request.response().end(new JsonObject().put("url", request.absoluteURI()).encode());
  }).listen(0, testContext.asyncAssertSuccess(server -> {

    Record sslRecord = HttpEndpoint.createRecord("http-bin", true, "127.0.0.1", server.actualPort(), "/get", null);
    ServiceReference reference = discovery.getReferenceWithConfiguration(sslRecord, new HttpClientOptions()
      .setSsl(true)
      .setTrustAll(true)
      .setVerifyHost(false)
      .toJson());

    WebClient webClient = WebClient.wrap(reference.get());
    webClient.get("/get").as(BodyCodec.jsonObject()).send(testContext.asyncAssertSuccess(resp -> {
      assertEquals("https://127.0.0.1:" + server.actualPort() + "/get", resp.body().getString("url"));
    }));
  }));
}
 
開發者ID:vert-x3,項目名稱:vertx-service-discovery,代碼行數:38,代碼來源:HttpEndpointTest.java

示例2: generateSelfSigned

import io.vertx.core.net.SelfSignedCertificate; //導入依賴的package包/類
private TrustAndKeyProvider generateSelfSigned(CoreContext core, String storeId) {
    core.logger(getClass())
            .event(LOG_SECURITY, Level.WARNING).send(getMissingKeyStore());

    return TrustAndKeyProvider.of(SelfSignedCertificate.create(CoreStrings.GITHUB));
}
 
開發者ID:codingchili,項目名稱:chili-core,代碼行數:7,代碼來源:SecuritySettings.java

示例3: of

import io.vertx.core.net.SelfSignedCertificate; //導入依賴的package包/類
/**
 * @param self a self signed certificate to get trust and keycert options from.
 * @return a new TrustAndKeyProvider instance.
 */
public static TrustAndKeyProvider of(SelfSignedCertificate self) {
    return new TrustAndKeyProvider(self.trustOptions(), self.keyCertOptions());
}
 
開發者ID:codingchili,項目名稱:chili-core,代碼行數:8,代碼來源:TrustAndKeyProvider.java


注:本文中的io.vertx.core.net.SelfSignedCertificate類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。