|
| 1 | +# Externalize API Gateway domain certificates |
| 2 | + |
| 3 | +## Admin Node manager |
| 4 | + |
| 5 | +- Create a CSR file |
| 6 | +```bash |
| 7 | +./gen_domain_cert.py --domain-id=dss --out=csr --O=Axway --OU=DSS --C=US --ST=AZ --L=Scottsdale --pass-file=rootcerts/pass.txt |
| 8 | +``` |
| 9 | +command creates a folder named dss under apigw-emt-scripts-2.1.0-SNAPSHOT/certs/ with following files |
| 10 | + |
| 11 | + - dss.csr |
| 12 | + - dss-key.pem |
| 13 | + |
| 14 | +- Create CA CSR, certificate and key |
| 15 | +```bash |
| 16 | +openssl genrsa -aes256 -out CA.key 2048 |
| 17 | +openssl req -new -sha256 -key CA.key -out CA.csr -subj "/C=US/ST=AZ/L=Scottsdale/O=AXWAY/CN=CACERTIFICATE" |
| 18 | +openssl x509 -signkey CA.key -in CA.csr -req -days 3650 -out CA.pem |
| 19 | +``` |
| 20 | +command creates following files |
| 21 | + |
| 22 | + - CA.key |
| 23 | + - CA.csr |
| 24 | + - CA.pem |
| 25 | + - CA.srl |
| 26 | + |
| 27 | +- Create a file openssl.cnf with following content |
| 28 | + |
| 29 | +```text |
| 30 | +[policy_any] |
| 31 | +domainComponent = optional |
| 32 | +organizationalUnitName = optional |
| 33 | +commonName = supplied |
| 34 | +
|
| 35 | +[req] |
| 36 | +distinguished_name = req_distinguished_name |
| 37 | +
|
| 38 | +[req_distinguished_name] |
| 39 | +
|
| 40 | +[x509_extensions] |
| 41 | +
|
| 42 | +[domain_extensions] |
| 43 | +basicConstraints = CA:TRUE, pathlen:0 |
| 44 | +keyUsage = digitalSignature, keyEncipherment, dataEncipherment, keyAgreement, keyCertSign |
| 45 | +
|
| 46 | +[admin_node_manager_extensions] |
| 47 | +basicConstraints = CA:FALSE |
| 48 | +keyUsage = digitalSignature, dataEncipherment, keyAgreement, keyEncipherment |
| 49 | +extendedKeyUsage = serverAuth, clientAuth, 1.3.6.1.4.1.17998.10.1.1.2.1, 1.3.6.1.4.1.17998.10.1.1.2.2 |
| 50 | +subjectAltName = @alt_names |
| 51 | +
|
| 52 | +[node_manager_extensions] |
| 53 | +basicConstraints = CA:FALSE |
| 54 | +keyUsage = digitalSignature, dataEncipherment, keyAgreement |
| 55 | +extendedKeyUsage = serverAuth, clientAuth, 1.3.6.1.4.1.17998.10.1.1.2.1 |
| 56 | +subjectAltName = @alt_names |
| 57 | +
|
| 58 | +[gateway_extensions] |
| 59 | +basicConstraints = CA:FALSE |
| 60 | +keyUsage = digitalSignature, dataEncipherment, keyAgreement |
| 61 | +extendedKeyUsage = serverAuth, clientAuth, 1.3.6.1.4.1.17998.10.1.1.2.3 |
| 62 | +subjectAltName = @alt_names |
| 63 | +
|
| 64 | +[alt_names] |
| 65 | +
|
| 66 | +DNS.1 = localhost |
| 67 | +IP.1 = 127.0.0.1 |
| 68 | +
|
| 69 | +``` |
| 70 | + |
| 71 | +- Sign dss.csr with CA certificate and key using openssl configuration |
| 72 | + |
| 73 | +```bash |
| 74 | +openssl x509 -req -days 360 -in dss.csr -CA CA.pem -CAkey CA.key -CAcreateserial -out signedbyCA.crt -sha256 -extensions admin_node_manager_extensions -extfile openssl.cnf |
| 75 | +``` |
| 76 | + |
| 77 | +- Create a P12 file from CA signed certificate and key file |
| 78 | + |
| 79 | +```bash |
| 80 | +openssl pkcs12 -export -in signedbyCA.crt -inkey dss-key.pem -out domain.p12 -chain -CAfile CA.pem -name 'topology-cert' |
| 81 | +``` |
| 82 | +**alias name should be 'topology-cert'** |
| 83 | + |
| 84 | +- Prepare Admin Node Manager fed file |
| 85 | + |
| 86 | + - Export Admin Node manager fed from classic installation, remove existing topology-cert and change remove / rename port name without blank space (e.g sslport) |
| 87 | + |
| 88 | + - Import loadable module |
| 89 | + Policystudio using File -> Import -> Import Custom filters -> select apim-policy-password-cert-env/src/main/resources/typeSet.xml. |
| 90 | + |
| 91 | + - Export fed file |
| 92 | + |
| 93 | +- Configure environment variable (docker-compose / kubernetes deployment) |
| 94 | + |
| 95 | +```yaml |
| 96 | + # docker-compose.yaml example |
| 97 | + environment: |
| 98 | + EMT_TOPOLOGY_LOG_ENABLED: 'true' |
| 99 | + EMT_TOPOLOGY_LOG_DEST: 3 |
| 100 | + certandkey_sslport: /opt/Axway/apigateway/domain.p12 |
| 101 | + certandkeypassword_sslport: changeme |
| 102 | + certandkeymtls_sslport: 'true' |
| 103 | +``` |
| 104 | + |
| 105 | +- comment lines related to certificate generation in apigw-emt-scripts-2.1.0-SNAPSHOT/Dockerfiles/emt-nodemanager/scripts/setup_emt_nodemanager.py |
| 106 | +```python |
| 107 | + try: |
| 108 | + # self._generateTopologyCert(nmHandler) |
| 109 | + # self._storeCertsInEntityStore(nmHandler) |
| 110 | + |
| 111 | + localNodeManager, topology, topologyParams = self._createTopologyJson() |
| 112 | + # print("Enabling SSL on management interface") |
| 113 | + # nmHandler.enableSSLInterface(True, TopologyCertificate.CERT_ALIAS, topologyParams) |
| 114 | + # self._updateConfigFiles(localNodeManager, topology) |
| 115 | + |
| 116 | + # Delete the cert generation temp directory |
| 117 | + shutil.rmtree(nmHandler.tempCertPath) |
| 118 | + |
| 119 | + except Exception, e: |
| 120 | + _fail("Error generating topology cert: %s" % e) |
| 121 | +``` |
| 122 | +- Build Admin Node Manger Image |
| 123 | +
|
| 124 | +```bash |
| 125 | +./build_anm_image.py --default-cert --default-user --parent-image=apigw-base --merge-dir=/Users/rnatarajan/APIM/apigw-emt-scripts-2.1.0-SNAPSHOT/apigateway --fed extanm.fed --out-image=admin-node-manager-ext-ca-env:latest |
| 126 | +``` |
| 127 | +**param default-cert is not used, but it is a mandatory argument for building anm image** |
| 128 | + |
| 129 | +## Configure Gateway |
| 130 | + |
| 131 | +- Create a CSR file |
| 132 | + |
| 133 | +```bash |
| 134 | +./gen_domain_cert.py --domain-id=dssgateway --out=csr --O=Axway --OU=DSS --C=US --ST=AZ --L=Scottsdale --pass-file=rootcerts/pass.txt |
| 135 | +``` |
| 136 | +command creates a folder named dssgateway under apigw-emt-scripts-2.1.0-SNAPSHOT/certs/ with following files |
| 137 | + |
| 138 | + - dssgateway.csr |
| 139 | + - dssgateway-key.pem |
| 140 | +- Copy CA.pem, CA.key, CA.srl and openssl files from dss folder to dssgateway folder |
| 141 | + |
| 142 | +```bash |
| 143 | +dssgateway$cp ../dss/CA.pem . |
| 144 | +dssgateway$cp ../dss/CA.key . |
| 145 | +dssgateway$cp ../dss/CA.srl . |
| 146 | +dssgateway$cp ../dss/openssl.cnf . |
| 147 | +``` |
| 148 | +- Sign dss.csr with CA certificate and key using openssl configuration |
| 149 | + |
| 150 | +```bash |
| 151 | +openssl x509 -req -days 360 -in dssgateway.csr -CA CA.pem -CAkey CA.key -CAcreateserial -out signedbygatewayCA.crt -sha256 -extensions gateway_extensions -extfile openssl.cnf |
| 152 | +``` |
| 153 | + |
| 154 | +command creates a file named signedbygatewayCA.crt |
| 155 | + |
| 156 | +- Create p12 file **without password** |
| 157 | + |
| 158 | +```bash |
| 159 | +openssl pkcs12 -export -in signedbygatewayCA.crt -inkey dssgateway-key.pem -out topology.p12 -chain -CAfile CA.pem -name 'topology-cert' -passout pass: |
| 160 | +``` |
| 161 | + |
| 162 | +- Prepare Admin Node Manager fed file |
| 163 | + |
| 164 | + - Import loadable module |
| 165 | + Policystudio using File -> Import -> Import Custom filters -> select apim-policy-password-cert-env/src/main/resources/typeSet.xml. |
| 166 | + |
| 167 | + - Export fed file |
| 168 | + |
| 169 | +- Configure environment variable (docker-compose / kubernetes deployment) |
| 170 | + |
| 171 | +```yaml |
| 172 | + # docker-compose.yaml example |
| 173 | + # Mandatory |
| 174 | + volumes: |
| 175 | + - /Users/rnatarajan/APIM/apigw-emt-scripts-2.1.0-SNAPSHOT/certs/dssgateway/p12:/opt/Axway/apigateway/groups/certs/ |
| 176 | + environment: |
| 177 | + EMT_ANM_HOSTS: nodemgr:8090 |
| 178 | + CASS0: host.docker.internal |
| 179 | + CASS_HOST: host.docker.internal |
| 180 | + CASS_USER: dba |
| 181 | + CASS_PASSWORD: super |
| 182 | + CASS_KEYSPACE: axwayapim |
| 183 | + # We should use same path |
| 184 | + gatewaytoplogycertandkey_domain: /opt/Axway/apigateway/groups/certs/topology.p12 |
| 185 | + gatewaytoplogycertandkeypassword_domain: '' |
| 186 | +``` |
| 187 | +
|
| 188 | +- comment lines related to certificate generation in apigw-emt-scripts-2.1.0-SNAPSHOT/Dockerfiles/emt-gateway/scripts/setup_emt_instance.py |
| 189 | +
|
| 190 | +```python |
| 191 | +def _setup(): |
| 192 | + _mergePolAndEnvToFed() |
| 193 | + _installCustomFedFile() |
| 194 | + _setupApiManager() |
| 195 | + _createInstanceDirStructure() |
| 196 | + _customizeInstallation() |
| 197 | + _checkLicense() |
| 198 | + |
| 199 | + # ch = CertHandler() |
| 200 | + # ch.generateCert() |
| 201 | + # ch.enableSSLInterface() |
| 202 | +``` |
| 203 | + |
| 204 | +- Build API Gateway Image |
| 205 | +```bash |
| 206 | +./build_gw_image.py --default-cert --license=/Users/rnatarajan/APIM/apigw-emt-scripts-2.1.0-SNAPSHOT/licenses/apim.lic --parent-image=apigw-base --merge-dir=/Users/rnatarajan/APIM/apigw-emt-scripts-2.1.0-SNAPSHOT/apigateway --fed=container_env.fed --out-image=apim-cert-ca-env:latest |
| 207 | +``` |
0 commit comments