Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Autoload self signed certificates from config/certs directory #292

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,6 +9,7 @@ api_test.sh
package-lock.json
src/config.json
config/local.json
config/certs/*.pem
var/magento2-sample-data/
.migrate
*.iml
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Extensions have ability to modify Elasticsearch results. @grimasod (#269)
- Refactored Travis build config @Tjitse-E (#273)
- Multistore support for `magento1`-platform using `magento1-vsbridge` @cewald (#276)
- Support self signed certificates - @lukeromanowicz (#287)

### Fixed
- Missing `res` and `req` parameters are now passed to ProductProcessor - @jahvi (#218)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -146,6 +146,11 @@ You can use the following command to run a delta indexer for a specific storevie
yarn mage2vs productsdelta --store-code=de
```

## Self signed certificates

Often in non production environment other services are using self signed certificates for secure connection.
You can easily setup the application to trust them by putting them in config/certs directory.

License
-------

Expand Down
Empty file added config/certs/.gitkeep
Empty file.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -92,7 +92,8 @@
"resource-router-middleware": "^0.6.0",
"sharp": "^0.21.0",
"soap": "^0.25.0",
"winston": "^2.4.2"
"winston": "^2.4.2",
"syswide-cas": "latest"
},
"devDependencies": {
"@types/body-parser": "^1.17.0",
Expand Down
13 changes: 13 additions & 0 deletions src/helpers/loadAdditionalCertificates.ts
@@ -0,0 +1,13 @@
import syswidecas from 'syswide-cas'
import * as fs from 'fs';

const CERTS_DIRECTORY = 'config/certs'

/**
* load certificates from certs directory and consider them trusted
*/
export const loadAdditionalCertificates = () => {
if (fs.existsSync(CERTS_DIRECTORY)) {
syswidecas.addCAs(CERTS_DIRECTORY);
}
}
3 changes: 3 additions & 0 deletions src/index.ts
Expand Up @@ -4,6 +4,7 @@ import morgan from 'morgan';
import bodyParser from 'body-parser';
import initializeDb from './db';
import middleware from './middleware';
import { loadAdditionalCertificates } from './helpers/loadAdditionalCertificates'
import api from './api';
import config from 'config';
import img from './api/img';
Expand All @@ -28,6 +29,8 @@ app.use(bodyParser.json({
limit : config.get('bodyLimit')
}));

loadAdditionalCertificates()

// connect to db
initializeDb( db => {
// internal middleware
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Expand Up @@ -4771,6 +4771,11 @@ supports-color@^5.2.0, supports-color@^5.3.0:
resolved "https://registry.yarnpkg.com/sylvester/-/sylvester-0.0.21.tgz#2987b1ce2bd2f38b0dce2a34388884bfa4400ea7"
integrity sha1-KYexzivS84sNzio0OIiEv6RADqc=

syswide-cas@latest:
version "5.3.0"
resolved "https://registry.yarnpkg.com/syswide-cas/-/syswide-cas-5.3.0.tgz#ef24b8580caa1c6d985b88cacfaa35db16982ed5"
integrity sha512-+RLgS6VInsX8rBpL+gy5qpa7phngecbK7NABelBZpqYpBTwOIK1y7CqHlXK5Vy/rA4erD9q/FyKzMjx2uX3zYg==

table@4.0.2:
version "4.0.2"
resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36"
Expand Down