use of com.github.tomakehurst.wiremock.common.BrowserProxySettings in project wiremock by wiremock.
the class GetCaCertTask method execute.
@Override
public ResponseDefinition execute(Admin admin, Request request, PathParams pathParams) {
BrowserProxySettings browserProxySettings = admin.getOptions().browserProxySettings();
KeyStoreSettings caKeyStore = browserProxySettings.caKeyStore();
try {
X509KeyStore x509KeyStore = new X509KeyStore(caKeyStore.loadStore(), caKeyStore.password().toCharArray());
X509Certificate certificate = x509KeyStore.getCertificateAuthority().certificateChain()[0];
return new ResponseDefinitionBuilder().withStatus(HTTP_OK).withHeader("Content-Type", "application/x-pem-file").withBody("-----BEGIN CERTIFICATE-----\r\n" + BASE64_ENCODER.encodeToString(certificate.getEncoded()) + "\r\n" + "-----END CERTIFICATE-----").build();
} catch (Exception e) {
String message = "Failed to export certificate authority cert from " + caKeyStore.path();
admin.getOptions().notifier().error(message, e);
return new ResponseDefinition(HTTP_INTERNAL_ERROR, message);
}
}
use of com.github.tomakehurst.wiremock.common.BrowserProxySettings in project wiremock by wiremock.
the class WireMockApp method buildStubRequestHandler.
public StubRequestHandler buildStubRequestHandler() {
Map<String, PostServeAction> postServeActions = options.extensionsOfType(PostServeAction.class);
BrowserProxySettings browserProxySettings = options.browserProxySettings();
return new StubRequestHandler(this, new StubResponseRenderer(options.filesRoot().child(FILES_ROOT), getGlobalSettingsHolder(), new ProxyResponseRenderer(options.proxyVia(), options.httpsSettings().trustStore(), options.shouldPreserveHostHeader(), options.proxyHostHeader(), globalSettingsHolder, browserProxySettings.trustAllProxyTargets(), browserProxySettings.trustedProxyTargets(), options.getStubCorsEnabled()), ImmutableList.copyOf(options.extensionsOfType(ResponseTransformer.class).values())), this, postServeActions, requestJournal, getStubRequestFilters(), options.getStubRequestLoggingDisabled());
}
Aggregations