Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public void configureAuthentication(OkHttpClient.Builder clientBuilder, MarkLogi
private Response callTokenEndpoint(MarkLogicCloudAuthContext securityContext) {
final HttpUrl tokenUrl = buildTokenUrl(securityContext);
OkHttpClient.Builder clientBuilder = OkHttpUtil.newClientBuilder();
// Initial testing has shown that neither the OkHttp socket factory nor hostname verifier need to be configured
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is likely wrong; it was only due to the "test" cloud instance I was using not doing any certificate verification.

// for the goal of invoking the token endpoint.
// Current assumption is that the SSL config provided for connecting to MarkLogic should also be applicable
// for connecting to MarkLogic Cloud's "/token" endpoint.
OkHttpUtil.configureSocketFactory(clientBuilder, securityContext.getSSLContext(), securityContext.getTrustManager());

if (logger.isInfoEnabled()) {
logger.info("Calling token endpoint at: " + tokenUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ private static void configureHostnameVerifier(OkHttpClient.Builder clientBuilder
* @param sslContext
* @param trustManager
*/
private static void configureSocketFactory(OkHttpClient.Builder clientBuilder, SSLContext sslContext, X509TrustManager trustManager) {
static void configureSocketFactory(OkHttpClient.Builder clientBuilder, SSLContext sslContext, X509TrustManager trustManager) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened this up for package-level access so that MarkLogicCloudAuthenticationConfigurer can reuse it. It's also used when constructing the OkHttpClient used for talking to MarkLogic.

/**
* Per https://square.github.io/okhttp/3.x/okhttp/okhttp3/OkHttpClient.Builder.html#sslSocketFactory-javax.net.ssl.SSLSocketFactory- ,
* OkHttp requires a TrustManager to be specified so that it can build a clean certificate chain. If trustManager
Expand Down