File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed 
src/main/java/org/opensearch/security/ssl Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -240,7 +240,7 @@ public Optional<SecureAuxTransportSettingsProvider> getSecureAuxTransportSetting
240240            @ Override 
241241            public  Optional <SSLContext > buildSecureAuxServerTransportContext (Settings  settings , AuxTransport  transport ) {
242242                CertType  auxCertType  = new  CertType (transport .settingKey ());
243-                 return  sslSettingsManager .sslContextHandler (auxCertType ).map (SslContextHandler ::sslContext );
243+                 return  sslSettingsManager .sslContextHandler (auxCertType ).map (SslContextHandler ::tryFetchSSLContext );
244244            }
245245
246246            @ Override 
Original file line number Diff line number Diff line change @@ -67,16 +67,24 @@ public SslConfiguration sslConfiguration() {
6767    }
6868
6969    /** 
70-      * Only JDK provider is supported, so we expect only JdkSslContext. 
71-      * @return null if context cannot be fetched from io.netty.handler.ssl.SslContext child type. 
70+      * Attempt to fetch the underlying io.netty.handler.ssl.SslContext as a javax SSLContext. 
71+      * As JDK is the only supported provider we expect sslContext is always of type JdkSslContext, 
72+      * allowing us to extract the javax.net.ssl.SSLContext delegate. Providing a javax SSLContext is 
73+      * desirable for dependencies which want to access security settings without taking on netty as a dependency. 
74+      * @return null if context cannot be fetched as JdkSslContext. 
7275     */ 
73-     public  SSLContext  sslContext () {
76+     public  SSLContext  tryFetchSSLContext () {
7477        if  (sslContext  instanceof  JdkSslContext ) {
7578            return  ((JdkSslContext ) sslContext ).context ();
7679        }
7780        return  null ;
7881    }
7982
83+     // public for testing 
84+     public  SslContext  sslContext () {
85+         return  sslContext ;
86+     }
87+ 
8088    public  Stream <Certificate > certificates () {
8189        return  Stream .concat (authorityCertificates (), keyMaterialCertificates ())
8290            .sorted ((c1 , c2 ) -> Boolean .compare (c1 .hasPrivateKey (), c2 .hasPrivateKey ()));
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments