@@ -138,6 +138,15 @@ private void updatePassword(EntityStore entityStore) {
138138 } catch (Exception e ) {
139139 Trace .error ("Unable to add the p12 from Environment variable" , e );
140140 }
141+ }else if (key .startsWith ("connecttourl_certandkey_" )) {
142+ try {
143+ char [] password = System .getenv ("connecttourl_certandkeypassword" + "_" + filterName ).toCharArray ();
144+ String alias = importP12 (entityStore , passwordValue , password );
145+ Trace .info ("P12 file alias name :" + alias );
146+ connectToURLConfigureP12 (entityStore , filterName , alias );
147+ } catch (Exception e ) {
148+ Trace .error ("Unable to add the p12 from Environment variable" , e );
149+ }
141150 }
142151 }
143152
@@ -362,22 +371,54 @@ private String importPublicCertificate(X509Certificate certificate, EntityStore
362371 private void configureP12 (EntityStore entityStore , String name , String alias ) {
363372
364373 String shorthandKey = "/[NetService]name=Service/[HTTP]**/[SSLInterface]name=" + name ;
365- ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder (entityStore );
366- List <Entity > entities = shorthandKeyFinder .getEntities (shorthandKey );
374+ //ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder(entityStore);
375+ //List<Entity> entities = shorthandKeyFinder.getEntities(shorthandKey);
376+ List <Entity > entities = getEntities (entityStore , shorthandKey );
367377 if (entities .isEmpty ()) {
368378 Trace .error ("Listener interface is not available" );
369379 return ;
380+ }else if (entities .size () > 1 ){
381+ Trace .error ("Found more than one Listener interface" );
382+ return ;
370383 }
371384 Entity entity = entities .get (0 );
385+ String fieldName = "serverCert" ;
386+ updateP12Cert (entityStore , entity , alias , fieldName );
387+ }
388+
389+ private List <Entity > getEntities (EntityStore entityStore , String shorthandKey ){
390+ ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder (entityStore );
391+ return shorthandKeyFinder .getEntities (shorthandKey );
392+ }
393+
394+ private void updateP12Cert (EntityStore entityStore , Entity entity , String alias , String fieldName ){
395+
372396 String escapedAlias = ShorthandKeyFinder .escapeFieldValue (alias );
373397 Entity certEntity = getCertEntity (entityStore , escapedAlias );
374398 //Trace.info("Certificate entity set to listener interface "+ certEntity);
375399 PortableESPK portableESPK = PortableESPK .toPortableKey (entityStore , certEntity .getPK ());
376400 //Trace.info("Portable : " + portableESPK);
377- entity .setReferenceField ("serverCert" , portableESPK );
401+ entity .setReferenceField (fieldName , portableESPK );
378402 entityStore .updateEntity (entity );
379403 }
380404
405+ private void connectToURLConfigureP12 (EntityStore entityStore , String name , String alias ) {
406+
407+ String shorthandKey = "/[FilterCircuit]**/[ConnectToURLFilter]name=" + name ;
408+ //ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder(entityStore);
409+ List <Entity > entities = getEntities (entityStore , shorthandKey );
410+ if (entities .isEmpty ()) {
411+ Trace .error ("Unable to find connect to URL filter" );
412+ return ;
413+ }else if (entities .size () > 1 ){
414+ Trace .error ("Found more than one connect to URL filter" );
415+ return ;
416+ }
417+ Entity entity = entities .get (0 );
418+ String fieldName = "sslusers" ;
419+ updateP12Cert (entityStore , entity , alias , fieldName );
420+ }
421+
381422 private Entity getCertEntity (EntityStore entityStore , String alias ) {
382423 String shorthandKey = "/[Certificates]name=Certificate Store" ;
383424 ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder (entityStore );
@@ -393,7 +434,7 @@ private Entity getCertEntity(EntityStore entityStore, String alias) {
393434
394435 private String importP12 (EntityStore entityStore , String cert , char [] password ) throws Exception {
395436
396- PKCS12 pkcs12 = null ;
437+ PKCS12 pkcs12 ;
397438 File file = new File (cert );
398439 if (file .exists ()){
399440 pkcs12 = certHelper .parseP12 (file , password );
0 commit comments