java - Spring Boot AsyncRestTemplate SSLSocketFactory -
deploying spring boot application in websphere. due ssl configuration, need explicitly specify sslsocketfactory ensure application uses websphere certificates , not default java key/trust stores.
doing via resttemplate straightforward:
protected resttemplate getresttemplate() { sslsocketfactory sslsocketfactory = new sslsocketfactory( (javax.net.ssl.sslsocketfactory) javax.net.ssl.sslsocketfactory.getdefault(), sslsocketfactory.browser_compatible_hostname_verifier ); schemeregistry registry = new schemeregistry(); registry.register(new scheme(http_scheme, http_port, plainsocketfactory.getsocketfactory())); registry.register(new scheme(https_scheme, https_port, sslsocketfactory)); basicclientconnectionmanager connectionmanager = new basicclientconnectionmanager(registry); defaulthttpclient httpclient = new defaulthttpclient(connectionmanager); clienthttprequestfactory requestfactory = new httpcomponentsclienthttprequestfactory(httpclient); return new resttemplate(requestfactory); }
however asyncresttemplate, unable find how set sslsocketfactory:
protected asyncresttemplate getasyncresttemplate() throws ioreactorexception, nosuchalgorithmexception { ssliosessionstrategy strategy = new ssliosessionstrategy( sslcontext.getdefault(), sslsocketfactory.browser_compatible_hostname_verifier ); registry<schemeiosessionstrategy> registry = registrybuilder.<schemeiosessionstrategy>create() .register(http_scheme, noopiosessionstrategy.instance) .register(https_scheme, strategy) .build(); poolingnhttpclientconnectionmanager connmanager = new poolingnhttpclientconnectionmanager( new defaultconnectingioreactor(), registry ); closeablehttpasyncclient httpclient = httpasyncclientbuilder .create() .setconnectionmanager(connmanager) .build(); asyncclienthttprequestfactory requestfactory = new httpcomponentsasyncclienthttprequestfactory(httpclient); return new asyncresttemplate(requestfactory); }
in essence, need call:
(javax.net.ssl.sslsocketfactory) javax.net.ssl.sslsocketfactory.getdefault()
which triggers websphere override ssl connection handling.
any ideas on i'm missing appreciated - thanks.
you cant. javax.net.socketfactory
incompatible nio based i/o models. there no way around using sslcontext
non-blocking ssl.
Comments
Post a Comment