Skip to content

Commit 2932cb6

Browse files
authored
Merge pull request #502 from ansforge/chore/lrm/server/migrate-cert
chore/lrm/server : use pem instead of pfx for ssl connection
2 parents 0375ae4 + 0033d98 commit 2932cb6

File tree

8 files changed

+3
-19
lines changed

8 files changed

+3
-19
lines changed

web/lrm/server/.env.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
HUB_URL=amqps://messaging.integration.hub.esante.gouv.fr
2-
LRM_PASSPHRASE=CHANGE_ME_mock_cert_password
32
GITHUB_TOKEN=mock_github_token
43
ADMIN_PASSWORD=mock_admin_password
54
VHOST_CLIENT_MAP={"15-15_v2.1": ["fr.health.test.samuA", "fr.health.test.samuB"]}

web/lrm/server/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
cp .env.template .env
99
```
1010

11-
- Set the value of `LRM_PASSPHRASE` to the passphrase of the server certificate to conect to RabbitMQ. Ask for the value to another member of the team.
12-
1311
- *Optional:* Update the content of the `.env` file:
1412
- `HUB_URL` controls the RabbitMQ instance the app will connect to. Use `amqps://messaging.<environment>.hub.esante.gouv.fr` to connect to a specific environment (or `amqps://messaging.hub.esante.gouv.fr` for production).
1513
- `GITHUB_TOKEN` is used to interract with Github API. It should be set to a valid token when working of the feature that consumes the Github API. See [Github documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens) on how to generate a personal token with the correct rights.

web/lrm/server/src/WebSocketHandler.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ beforeEach(() => {
1212
...originalEnv,
1313
ADMIN_PASSWORD: 'foo',
1414
HUB_URL: 'foo',
15-
LRM_PASSPHRASE: 'foo',
1615
VHOST_CLIENT_MAP: JSON.stringify({
1716
'15-15_v1.5': ['fr.health.test.samuV1', 'fr.health.test.samuA'],
1817
'15-15_v2.0': ['fr.health.test.samuV2', 'fr.health.test.samuB'],

web/lrm/server/src/config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export class Config {
77
private readonly port: number;
88
private readonly adminPassword: string;
99
private readonly hubUrl: string;
10-
private readonly lrmCertPassphrase: string;
1110
private readonly hubSanteExchange: string;
1211
private readonly vhostClientMap: VhostClientMap;
1312
private readonly logger: Logger;
@@ -16,7 +15,6 @@ export class Config {
1615
this.port = this.extractNumericEnvVar('PORT', 8081);
1716
this.adminPassword = this.extractEnvVar('ADMIN_PASSWORD');
1817
this.hubUrl = this.extractEnvVar('HUB_URL');
19-
this.lrmCertPassphrase = this.extractEnvVar('LRM_PASSPHRASE');
2018
this.hubSanteExchange = 'hubsante';
2119
this.vhostClientMap = JSON.parse(this.extractEnvVar('VHOST_CLIENT_MAP'));
2220
this.logger = logger.child({ component: 'Config' });
@@ -55,10 +53,6 @@ export class Config {
5553
return this.hubUrl;
5654
}
5755

58-
public getLrmCertPassphrase() {
59-
return this.lrmCertPassphrase;
60-
}
61-
6256
public getHubSanteExchange() {
6357
return this.hubSanteExchange;
6458
}

web/lrm/server/src/expressServer.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ beforeEach(() => {
4949
...originalEnv,
5050
ADMIN_PASSWORD: 'foo',
5151
HUB_URL: 'foo',
52-
LRM_PASSPHRASE: 'foo',
5352
VHOST_CLIENT_MAP: JSON.stringify({
5453
'15-15_v1.5': ['fr.health.test.samuV1', 'fr.health.test.samuA'],
5554
'15-15_v2.0': ['fr.health.test.samuV2', 'fr.health.test.samuB'],
-3.89 KB
Binary file not shown.

web/lrm/server/src/rabbit/utils.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,17 @@ export class RabbitMQConnector {
1414
this.config = config;
1515
this.connectionOptions = {
1616
...this.readCerts(),
17-
passphrase: this.config.getLrmCertPassphrase(),
1817
credentials: credentials.external(),
1918
clientProperties: { connection_name: 'lrm-interface' },
2019
};
2120
this.logger = logger.child({ component: 'RabbitMQConnector' });
2221
}
2322

24-
private readCerts(): { pfx: Buffer<ArrayBufferLike>; ca: Buffer<ArrayBufferLike>[] } {
23+
private readCerts(): { cert: Buffer<ArrayBufferLike>; key: Buffer<ArrayBufferLike>; ca: Buffer<ArrayBufferLike>[] } {
2524
const moduleDir = __dirname;
2625
return {
27-
// pfx with new encryption needed for Node 19 support
28-
// Ref: https://github.com/nodejs/node/issues/40672#issuecomment-1680460423
29-
pfx: readFileSync(join(moduleDir, 'certs/lrm_test.pfx')),
30-
// cert: fs.readFileSync(path.join(moduleDir, 'certs/local_test.crt')), // client cert
31-
// key: fs.readFileSync(path.join(moduleDir, 'certs/local_test.key')), // client key
26+
cert: readFileSync(join(moduleDir, 'certs/tls.crt')), // client cert
27+
key: readFileSync(join(moduleDir, 'certs/tls.key')), // client key
3228
ca: [readFileSync(join(moduleDir, 'certs/rootCA.crt'))], // array of trusted CA certs
3329
// Ref.: https://github.com/amqp-node/amqplib/issues/105
3430
};

web/lrm/server/src/service/messaging.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ beforeEach(() => {
4343
...originalEnv,
4444
ADMIN_PASSWORD: 'foo',
4545
HUB_URL: 'foo',
46-
LRM_PASSPHRASE: 'foo',
4746
VHOST_CLIENT_MAP: JSON.stringify({
4847
'15-15_v1.5': ['fr.health.test.samuV1'],
4948
}),

0 commit comments

Comments
 (0)