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
9 changes: 8 additions & 1 deletion .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,29 @@ ZGIu5manaCW4XJKyZU/Kp04JR6ojQai65R/OLaFOxQhdZ9rtIN1DAsyTBp/6tqqC
s2+QnHEKNi5n6eyF81l1X3AGOMp2uUF4CfU=
-----END CERTIFICATE-----"
```
- PKCS12 - To update the https listener certificate. There are two environment variables used to setup certificate on Listener interface

- Connect to URL SSL ( 2-Way SSL / Mutual SSL) Authentication

To update Connect to URL SSL certificate, there are two environment variables used to set up certificate for SSL Authentication

-- connecttourl_certandkey_sslauth

-- certandkeypassword_sslauth

```bash
$export connecttourl_certandkey_sslauth="MIIL5gIBAzCCC7AGCSqGSIb3DQEHAaCCC6EEggudMIILmTCCBi8GCSqGSIb3DQEHBqCCBiAwggYcAgEAMIIGFQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQI9bSw5/Kr0SsCAggAgIIF6DTG3vfPtoc4NPgJE9FU43PRyMpBcv/JIefNDTvC5CNQ+7b47Afqo6mJFIndSxTEbHcnWNG/ufC2/C+7oTn8aZyrgi868fgysv9knhOe+tPJ1O6RyF690m00CmoRhE4kCDKMPaAeRR2ZAMAqj9nPrxjWMXKdrS8+LeEhq2SYSozP8VR+llaTrDPtO8+mC9KRfJIgrKpbB0G/qdnJNtrhJJ8fhaE+/Ufkhydwe0tldu+kOGMODCWVpCY5q2MRrQlhvQhLOYJ7LA/Ovz1ZDjOAE9oujqvhegDxwHj4I6sxHYhGsPUYstNiiqpI5ZcODxUajd5JmEGytk9LU/9PtKEQrXMB4/H7RsRV2bVMWtDaHVW5g0h0oUTw5SBJuPEZMljfLSIXiazerlDC5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Mj3Ocpmf/cJhTZl7wro2x+p/opJYqdKbMOaA+8orsU5r9BCv7NZFh278fSo3fpPut9+ZpmSaYDPpDjAuYlpzv1NFTyAz8Q2myFWFHSxh+KnSfhrEtf4euDRgQ/9gZ2IqXUsZ3FXUNtymfMUYwHwYJKoZIhvcNAQkUMRIeEABDAE4APQBhAHgAdwBhAHkwIwYJKoZIhvcNAQkVMRYEFFnwiPQwNks1gKUHDM3ye/ArMTPaMC0wITAJBgUrDgMCGgUABBQMVJgNbDx/sDqV37rk+lgsiaWPhgQIXKMl/uHVEFw"

# Use file path - file should be created via config map / mount
$export connecttourlcertandkey_sslauth = /opt/Axway/apigateway/certs/cert.p12

# Use k8s secret to manage password
$export connecttourlcertandkey_sslauth=changeit
```
**sslauth** is the name of Connect to URL filter **WARNING**: Do not use blank spaces in Connect to URL filter name.

![secureport Interface](images/connect2urlsslauth.PNG)

- PKCS12 - To update the https listener certificate. There are two environment variables used to set up certificate on Listener interface

-- certandkey_secureport

Expand All @@ -192,11 +214,10 @@ $export certandkey_secureport = /opt/Axway/apigateway/certs/cert.p12
# Use k8s secret to manage password
$export certandkeypassword_secureport=changeit
```
**secureport** is the name of the https interface.
**secureport** is the name of the https interface **WARNING**: Do not use blank spaces.

![secureport Interface](images/https_interface.png)

The PKCS12 file is base64 encoded, it will be changed to file ( reading from an external drive or ??)

## Build the project

Expand Down Expand Up @@ -228,6 +249,8 @@ $mvn clean install

- Add Loadable module to running gateway using publish script or Import apim-policy-password-cert-env/src/main/resources/typeSet.xml via Policystudio using File -> Import -> Import Custom filters.

(or)

- Parameters of publish command
```bash
Options:
Expand Down
Binary file added images/connect2urlsslauth.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 15 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.axway</groupId>
<artifactId>apim-env-module</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>

<name>apim-env-module</name>
<url>https://axway.com</url>
Expand All @@ -16,7 +16,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<api.version>7.7</api.version>
<apim.lib.path>/Users/rnatarajan/AxwayProducts/apim_7_7/lib</apim.lib.path>
<apim.lib.path>/Users/rnatarajan/AxwayProducts/apim_7_7_nov/lib</apim.lib.path>
</properties>

<dependencies>
Expand All @@ -31,56 +31,57 @@
<artifactId>apigw-common</artifactId>
<scope>system</scope>
<version>${api.version}</version>
<systemPath>${apim.lib.path}/plugins/apigw-common-7.7.0.1-4.jar</systemPath>
<systemPath>${apim.lib.path}/plugins/apigw-common-2.0.1.jar</systemPath>
</dependency>
<dependency>
<groupId>vordel-trace</groupId>
<artifactId>vordel-trace</artifactId>
<scope>system</scope>
<version>${api.version}</version>
<systemPath>${apim.lib.path}/plugins/vordel-trace-7.7.0.1-4.jar</systemPath>
<systemPath>${apim.lib.path}/plugins/vordel-trace-7.7.0.20201130-5.jar</systemPath>
</dependency>
<dependency>
<groupId>server</groupId>
<artifactId>server</artifactId>
<groupId>vordel-apigateway</groupId>
<artifactId>vordel-apigateway</artifactId>
<scope>system</scope>
<version>${api.version}</version>
<systemPath>${apim.lib.path}/server.jar</systemPath>
<systemPath>${apim.lib.path}/vordel-apigateway-7.7.0.20201130-5.jar</systemPath>
</dependency>
<dependency>
<groupId>precipitate</groupId>
<artifactId>precipitate</artifactId>

<groupId>vordel-core-runtime</groupId>
<artifactId>vordel-core-runtime</artifactId>
<scope>system</scope>
<version>${api.version}</version>
<systemPath>${apim.lib.path}/precipitate.jar</systemPath>
<systemPath>${apim.lib.path}/vordel-core-runtime-7.7.0.20201130-5.jar</systemPath>
</dependency>
<dependency>
<groupId>es-core</groupId>
<artifactId>es-core</artifactId>
<scope>system</scope>
<version>${api.version}</version>
<systemPath>${apim.lib.path}/plugins/es-core-7.7.0.1-4.jar</systemPath>
<systemPath>${apim.lib.path}/plugins/es-core-2.0.4.jar</systemPath>
</dependency>
<dependency>
<groupId>vordel-common</groupId>
<artifactId>vordel-common</artifactId>
<scope>system</scope>
<version>${api.version}</version>
<systemPath>${apim.lib.path}/plugins/vordel-common-7.7.0.1-4.jar</systemPath>
<systemPath>${apim.lib.path}/plugins/vordel-common-7.7.0.20201130-5.jar</systemPath>
</dependency>
<dependency>
<groupId>vordel-system</groupId>
<artifactId>vordel-system</artifactId>
<scope>system</scope>
<version>${api.version}</version>
<systemPath>${apim.lib.path}/plugins/vordel-system-7.7.0.1-4.jar</systemPath>
<systemPath>${apim.lib.path}/plugins/vordel-system-7.7.0.20201130-5.jar</systemPath>
</dependency>
<dependency>
<groupId>vordel-config</groupId>
<artifactId>vordel-config</artifactId>
<scope>system</scope>
<version>${api.version}</version>
<systemPath>${apim.lib.path}/plugins/vordel-config-7.7.0.1-4.jar</systemPath>
<systemPath>${apim.lib.path}/plugins/vordel-config-7.7.0.20201130-5.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down
53 changes: 48 additions & 5 deletions src/main/java/com/axway/ExternalConfigLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class ExternalConfigLoader implements LoadableModule {

private static final Logger log = LogManager.getLogger(ExternalConfigLoader.class);
private CertHelper certHelper = new CertHelper();
private final CertHelper certHelper = new CertHelper();
private PasswordCipher passwordCipher;


Expand Down Expand Up @@ -131,13 +131,24 @@ private void updatePassword(EntityStore entityStore) {
}
} else if (key.startsWith("certandkey_")) {
try {
Trace.info("Updating SSL interface certificate and key");
char[] password = System.getenv("certandkeypassword" + "_" + filterName).toCharArray();
String alias = importP12(entityStore, passwordValue, password);
Trace.info("P12 file alias name :" + alias);
configureP12(entityStore, filterName, alias);
} catch (Exception e) {
Trace.error("Unable to add the p12 from Environment variable", e);
}
}else if (key.startsWith("connecttourlcertandkey_")) {
try {
Trace.info("Updating Connect to URL client Auth certificate and key");
char[] password = System.getenv("connecttourlcertandkeypassword" + "_" + filterName).toCharArray();
String alias = importP12(entityStore, passwordValue, password);
Trace.info("P12 file alias name :" + alias);
connectToURLConfigureP12(entityStore, filterName, alias);
} catch (Exception e) {
Trace.error("Unable to add the p12 from Environment variable", e);
}
}
}

Expand Down Expand Up @@ -362,22 +373,54 @@ private String importPublicCertificate(X509Certificate certificate, EntityStore
private void configureP12(EntityStore entityStore, String name, String alias) {

String shorthandKey = "/[NetService]name=Service/[HTTP]**/[SSLInterface]name=" + name;
ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder(entityStore);
List<Entity> entities = shorthandKeyFinder.getEntities(shorthandKey);
//ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder(entityStore);
//List<Entity> entities = shorthandKeyFinder.getEntities(shorthandKey);
List<Entity> entities = getEntities(entityStore, shorthandKey);
if (entities.isEmpty()) {
Trace.error("Listener interface is not available");
return;
}else if(entities.size() > 1){
Trace.error("Found more than one Listener interface");
return;
}
Entity entity = entities.get(0);
String fieldName = "serverCert";
updateP12Cert(entityStore, entity, alias, fieldName);
}

private List<Entity> getEntities(EntityStore entityStore, String shorthandKey){
ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder(entityStore);
return shorthandKeyFinder.getEntities(shorthandKey);
}

private void updateP12Cert(EntityStore entityStore, Entity entity, String alias, String fieldName){

String escapedAlias = ShorthandKeyFinder.escapeFieldValue(alias);
Entity certEntity = getCertEntity(entityStore, escapedAlias);
//Trace.info("Certificate entity set to listener interface "+ certEntity);
PortableESPK portableESPK = PortableESPK.toPortableKey(entityStore, certEntity.getPK());
//Trace.info("Portable : " + portableESPK);
entity.setReferenceField("serverCert", portableESPK);
entity.setReferenceField(fieldName, portableESPK);
entityStore.updateEntity(entity);
}

private void connectToURLConfigureP12(EntityStore entityStore, String name, String alias) {

String shorthandKey = "/[FilterCircuit]**/[ConnectToURLFilter]name=" + name;
//ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder(entityStore);
List<Entity> entities = getEntities(entityStore, shorthandKey);
if (entities.isEmpty()) {
Trace.error("Unable to find connect to URL filter");
return;
}else if(entities.size() > 1){
Trace.error("Found more than one connect to URL filter");
return;
}
Entity entity = entities.get(0);
String fieldName = "sslUsers";
updateP12Cert(entityStore, entity, alias, fieldName);
}

private Entity getCertEntity(EntityStore entityStore, String alias) {
String shorthandKey = "/[Certificates]name=Certificate Store";
ShorthandKeyFinder shorthandKeyFinder = new ShorthandKeyFinder(entityStore);
Expand All @@ -393,7 +436,7 @@ private Entity getCertEntity(EntityStore entityStore, String alias) {

private String importP12(EntityStore entityStore, String cert, char[] password) throws Exception {

PKCS12 pkcs12 = null;
PKCS12 pkcs12;
File file = new File(cert);
if(file.exists()){
pkcs12 = certHelper.parseP12(file, password);
Expand Down