private void clientCertCheck ( ) { boolean enableClientCert = getBoolean ( USE_CLIENT_CERT , false ) ; String certPath = getString ( CLIENT_CERT_LOCATION , "" ) ; String certPass = getString ( CLIENT_CERT_PASSWORD , "" ) ; int certIndex = getInt ( CLIENT_CERT_INDEX , 0 ) ; if ( enableClientCert && ! certPath . isEmpty ( ) && ! certPass . isEmpty ( ) ) { try { SSLContextManager contextManager = getSSLContextManager ( ) ; int ksIndex = contextManager . loadPKCS12Certificate ( certPath , certPass ) ; contextManager . unlockKey ( ksIndex , certIndex , certPass ) ; contextManager . setDefaultKey ( ksIndex , certIndex ) ; setActiveCertificate ( ) ; setEnableCertificate ( true ) ; logger . info ( "Client Certificate enabled from CLI" ) ; logger . info ( "Use -config certificate.persist=true to save settings" ) ; } catch ( IOException | CertificateException | NoSuchAlgorithmException | KeyStoreException | KeyManagementException ex ) { logger . error ( "The certificate could not be enabled due to an error" , ex ) ; } } }
Enables ClientCertificate from - config CLI parameters Requires location password and a flag to use client certificate .