@zetra/citrineos-certificates 1.8.3-fork.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/module/2.0.1/MessageApi.d.ts +35 -0
- package/dist/module/2.0.1/MessageApi.js +108 -0
- package/dist/module/2.0.1/MessageApi.js.map +1 -0
- package/dist/module/DataApi.d.ts +72 -0
- package/dist/module/DataApi.js +321 -0
- package/dist/module/DataApi.js.map +1 -0
- package/dist/module/installCertificateHelperService.d.ts +49 -0
- package/dist/module/installCertificateHelperService.js +282 -0
- package/dist/module/installCertificateHelperService.js.map +1 -0
- package/dist/module/interface.d.ts +5 -0
- package/dist/module/interface.js +5 -0
- package/dist/module/interface.js.map +1 -0
- package/dist/module/module.d.ts +93 -0
- package/dist/module/module.js +429 -0
- package/dist/module/module.js.map +1 -0
- package/package.json +28 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CertificatesOcpp201Api } from './module/2.0.1/MessageApi.js';
|
|
2
|
+
export { CertificatesDataApi } from './module/DataApi.js';
|
|
3
|
+
export type { ICertificatesModuleApi } from './module/interface.js';
|
|
4
|
+
export { CertificatesModule } from './module/module.js';
|
|
5
|
+
export { InstallCertificateHelperService } from './module/installCertificateHelperService.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2025 Contributors to the CitrineOS Project
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
export { CertificatesOcpp201Api } from './module/2.0.1/MessageApi.js';
|
|
5
|
+
export { CertificatesDataApi } from './module/DataApi.js';
|
|
6
|
+
export { CertificatesModule } from './module/module.js';
|
|
7
|
+
export { InstallCertificateHelperService } from './module/installCertificateHelperService.js';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,sCAAsC;AAEtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CallAction, IMessageConfirmation } from '@citrineos/base';
|
|
2
|
+
import { AbstractModuleApi, OCPP2_0_1 } from '@citrineos/base';
|
|
3
|
+
import type { FastifyInstance } from 'fastify';
|
|
4
|
+
import type { ILogObj } from 'tslog';
|
|
5
|
+
import { Logger } from 'tslog';
|
|
6
|
+
import type { ICertificatesModuleApi } from '../interface.js';
|
|
7
|
+
import { CertificatesModule } from '../module.js';
|
|
8
|
+
/**
|
|
9
|
+
* Server API for the Certificates module.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CertificatesOcpp201Api extends AbstractModuleApi<CertificatesModule> implements ICertificatesModuleApi {
|
|
12
|
+
/**
|
|
13
|
+
* Constructs a new instance of the class.
|
|
14
|
+
*
|
|
15
|
+
* @param {CertificatesModule} certificatesModule - The Certificates module.
|
|
16
|
+
* @param {FastifyInstance} server - The Fastify server instance.
|
|
17
|
+
* @param {Logger<ILogObj>} [logger] - The logger instance.
|
|
18
|
+
*/
|
|
19
|
+
constructor(certificatesModule: CertificatesModule, server: FastifyInstance, logger?: Logger<ILogObj>);
|
|
20
|
+
/**
|
|
21
|
+
* Interface implementation
|
|
22
|
+
*/
|
|
23
|
+
certificateSigned(identifier: string[], request: OCPP2_0_1.CertificateSignedRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
|
|
24
|
+
installCertificate(identifier: string[], request: OCPP2_0_1.InstallCertificateRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
|
|
25
|
+
getInstalledCertificateIds(identifier: string[], request: OCPP2_0_1.GetInstalledCertificateIdsRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
|
|
26
|
+
deleteCertificate(identifier: string[], request: OCPP2_0_1.DeleteCertificateRequest, callbackUrl?: string, tenantId?: number): Promise<IMessageConfirmation[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Overrides superclass method to generate the URL path based on the input {@link CallAction}
|
|
29
|
+
* and the module's endpoint prefix configuration.
|
|
30
|
+
*
|
|
31
|
+
* @param {CallAction} input - The input {@link CallAction}.
|
|
32
|
+
* @return {string} - The generated URL path.
|
|
33
|
+
*/
|
|
34
|
+
protected _toMessagePath(input: CallAction): string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { AbstractModuleApi, AsMessageEndpoint, DEFAULT_TENANT_ID, OCPP2_0_1, OCPP2_0_1_CallAction, OCPPVersion, } from '@citrineos/base';
|
|
11
|
+
import { Logger } from 'tslog';
|
|
12
|
+
import { CertificatesModule } from '../module.js';
|
|
13
|
+
import { DeleteCertificateAttempt } from '@citrineos/data';
|
|
14
|
+
/**
|
|
15
|
+
* Server API for the Certificates module.
|
|
16
|
+
*/
|
|
17
|
+
export class CertificatesOcpp201Api extends AbstractModuleApi {
|
|
18
|
+
/**
|
|
19
|
+
* Constructs a new instance of the class.
|
|
20
|
+
*
|
|
21
|
+
* @param {CertificatesModule} certificatesModule - The Certificates module.
|
|
22
|
+
* @param {FastifyInstance} server - The Fastify server instance.
|
|
23
|
+
* @param {Logger<ILogObj>} [logger] - The logger instance.
|
|
24
|
+
*/
|
|
25
|
+
constructor(certificatesModule, server, logger) {
|
|
26
|
+
super(certificatesModule, server, OCPPVersion.OCPP2_0_1, logger);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Interface implementation
|
|
30
|
+
*/
|
|
31
|
+
certificateSigned(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
|
|
32
|
+
const results = identifier.map((id) => this._module.sendCall(id, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.CertificateSigned, request, callbackUrl));
|
|
33
|
+
return Promise.all(results);
|
|
34
|
+
}
|
|
35
|
+
installCertificate(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
|
|
36
|
+
const results = identifier.map(async (id) => {
|
|
37
|
+
await this._module.installCertificateHelperService.prepareToInstallCertificate(tenantId, id, request.certificate, request.certificateType);
|
|
38
|
+
return this._module.sendCall(id, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.InstallCertificate, request, callbackUrl);
|
|
39
|
+
});
|
|
40
|
+
return Promise.all(results);
|
|
41
|
+
}
|
|
42
|
+
getInstalledCertificateIds(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
|
|
43
|
+
const results = identifier.map((id) => this._module.sendCall(id, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.GetInstalledCertificateIds, request, callbackUrl));
|
|
44
|
+
return Promise.all(results);
|
|
45
|
+
}
|
|
46
|
+
deleteCertificate(identifier, request, callbackUrl, tenantId = DEFAULT_TENANT_ID) {
|
|
47
|
+
const results = identifier.map(async (id) => {
|
|
48
|
+
const certificateHashData = request.certificateHashData;
|
|
49
|
+
const existingPendingDeleteCertificateAttempt = await this._module.deleteCertificateAttemptRepository.readOnlyOneByQuery(tenantId, {
|
|
50
|
+
where: {
|
|
51
|
+
stationId: id,
|
|
52
|
+
hashAlgorithm: certificateHashData.hashAlgorithm,
|
|
53
|
+
issuerNameHash: certificateHashData.issuerNameHash,
|
|
54
|
+
issuerKeyHash: certificateHashData.issuerKeyHash,
|
|
55
|
+
serialNumber: certificateHashData.serialNumber,
|
|
56
|
+
status: null,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
if (!existingPendingDeleteCertificateAttempt) {
|
|
60
|
+
const deleteCertificateAttempt = new DeleteCertificateAttempt();
|
|
61
|
+
deleteCertificateAttempt.stationId = id;
|
|
62
|
+
deleteCertificateAttempt.hashAlgorithm = certificateHashData.hashAlgorithm;
|
|
63
|
+
deleteCertificateAttempt.issuerNameHash = certificateHashData.issuerNameHash;
|
|
64
|
+
deleteCertificateAttempt.issuerKeyHash = certificateHashData.issuerKeyHash;
|
|
65
|
+
deleteCertificateAttempt.serialNumber = certificateHashData.serialNumber;
|
|
66
|
+
await deleteCertificateAttempt.save();
|
|
67
|
+
}
|
|
68
|
+
return this._module.sendCall(id, tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.DeleteCertificate, request, callbackUrl);
|
|
69
|
+
});
|
|
70
|
+
return Promise.all(results);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Overrides superclass method to generate the URL path based on the input {@link CallAction}
|
|
74
|
+
* and the module's endpoint prefix configuration.
|
|
75
|
+
*
|
|
76
|
+
* @param {CallAction} input - The input {@link CallAction}.
|
|
77
|
+
* @return {string} - The generated URL path.
|
|
78
|
+
*/
|
|
79
|
+
_toMessagePath(input) {
|
|
80
|
+
const endpointPrefix = this._module.config.modules.certificates?.endpointPrefix;
|
|
81
|
+
return super._toMessagePath(input, endpointPrefix);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
__decorate([
|
|
85
|
+
AsMessageEndpoint(OCPP2_0_1_CallAction.CertificateSigned, OCPP2_0_1.CertificateSignedRequestSchema),
|
|
86
|
+
__metadata("design:type", Function),
|
|
87
|
+
__metadata("design:paramtypes", [Array, Object, String, Number]),
|
|
88
|
+
__metadata("design:returntype", Promise)
|
|
89
|
+
], CertificatesOcpp201Api.prototype, "certificateSigned", null);
|
|
90
|
+
__decorate([
|
|
91
|
+
AsMessageEndpoint(OCPP2_0_1_CallAction.InstallCertificate, OCPP2_0_1.InstallCertificateRequestSchema),
|
|
92
|
+
__metadata("design:type", Function),
|
|
93
|
+
__metadata("design:paramtypes", [Array, Object, String, Number]),
|
|
94
|
+
__metadata("design:returntype", Promise)
|
|
95
|
+
], CertificatesOcpp201Api.prototype, "installCertificate", null);
|
|
96
|
+
__decorate([
|
|
97
|
+
AsMessageEndpoint(OCPP2_0_1_CallAction.GetInstalledCertificateIds, OCPP2_0_1.GetInstalledCertificateIdsRequestSchema),
|
|
98
|
+
__metadata("design:type", Function),
|
|
99
|
+
__metadata("design:paramtypes", [Array, Object, String, Number]),
|
|
100
|
+
__metadata("design:returntype", Promise)
|
|
101
|
+
], CertificatesOcpp201Api.prototype, "getInstalledCertificateIds", null);
|
|
102
|
+
__decorate([
|
|
103
|
+
AsMessageEndpoint(OCPP2_0_1_CallAction.DeleteCertificate, OCPP2_0_1.DeleteCertificateRequestSchema),
|
|
104
|
+
__metadata("design:type", Function),
|
|
105
|
+
__metadata("design:paramtypes", [Array, Object, String, Number]),
|
|
106
|
+
__metadata("design:returntype", Promise)
|
|
107
|
+
], CertificatesOcpp201Api.prototype, "deleteCertificate", null);
|
|
108
|
+
//# sourceMappingURL=MessageApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageApi.js","sourceRoot":"","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-0,0 +1,72 @@
|
|
|
1
|
+
import { AbstractModuleApi, type IFileStorage, type IMessageConfirmation, type IMessageQuerystring, Namespace, OCPP1_6_Namespace, OCPP2_0_1_Namespace, type WebsocketServerConfig } from '@citrineos/base';
|
|
2
|
+
import { Certificate, GenerateCertificateChainRequest, InstalledCertificate, InstallRootCertificateRequest, RegenerateExistingCertificate, type TenantQueryString, TlsCertificatesRequest, type UpdateTlsCertificateQueryString, UploadExistingCertificate } from '@citrineos/data';
|
|
3
|
+
import type { FastifyInstance, FastifyRequest } from 'fastify';
|
|
4
|
+
import type { ILogObj } from 'tslog';
|
|
5
|
+
import { Logger } from 'tslog';
|
|
6
|
+
import type { ICertificatesModuleApi } from './interface.js';
|
|
7
|
+
import { CertificatesModule } from './module.js';
|
|
8
|
+
/**
|
|
9
|
+
* Server API for the Certificates module.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CertificatesDataApi extends AbstractModuleApi<CertificatesModule> implements ICertificatesModuleApi {
|
|
12
|
+
private readonly _websocketServersConfig;
|
|
13
|
+
private readonly _fileStorage;
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a new instance of the class.
|
|
16
|
+
*
|
|
17
|
+
* @param {CertificatesModule} certificatesModule - The Certificates module.
|
|
18
|
+
* @param {FastifyInstance} server - The Fastify server instance.
|
|
19
|
+
* @param {IFileStorage} fileStorage - The fileStorage
|
|
20
|
+
* @param {WebsocketServerConfig[]} websocketServersConfig - Configuration for websocket servers
|
|
21
|
+
* @param {Logger<ILogObj>} [logger] - The logger instance.
|
|
22
|
+
*/
|
|
23
|
+
constructor(certificatesModule: CertificatesModule, server: FastifyInstance, fileStorage: IFileStorage, websocketServersConfig: WebsocketServerConfig[], logger?: Logger<ILogObj>);
|
|
24
|
+
/**
|
|
25
|
+
* Data Endpoint Methods
|
|
26
|
+
*/
|
|
27
|
+
putTlsCertificates(request: FastifyRequest<{
|
|
28
|
+
Body: TlsCertificatesRequest;
|
|
29
|
+
Querystring: UpdateTlsCertificateQueryString;
|
|
30
|
+
}>): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* This endpoint is used to create certificate chain, root CA, sub CA and leaf certificate
|
|
33
|
+
*
|
|
34
|
+
* @param request - GenerateRootCertificatesRequest
|
|
35
|
+
* @return Promise<Certificate[]> - An array of generated certificates
|
|
36
|
+
*/
|
|
37
|
+
generateCertificateChain(request: FastifyRequest<{
|
|
38
|
+
Body: GenerateCertificateChainRequest;
|
|
39
|
+
Querystring: TenantQueryString;
|
|
40
|
+
}>): Promise<Certificate[]>;
|
|
41
|
+
installRootCertificate(request: FastifyRequest<{
|
|
42
|
+
Body: InstallRootCertificateRequest;
|
|
43
|
+
}>): Promise<IMessageConfirmation>;
|
|
44
|
+
/**
|
|
45
|
+
* Endpoint to upload an existing certificate that is already installed on a given station to the CSMS
|
|
46
|
+
* @param request - UploadExistingCertificateSchema
|
|
47
|
+
* @return Promise<InstalledCertificate> - the installed certificate record
|
|
48
|
+
*/
|
|
49
|
+
uploadExistingCertificate(request: FastifyRequest<{
|
|
50
|
+
Body: UploadExistingCertificate;
|
|
51
|
+
Querystring: IMessageQuerystring;
|
|
52
|
+
}>): Promise<InstalledCertificate[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Endpoint to regenerate an existing certificate that is already installed on a given station.
|
|
55
|
+
* Updates the InstalledCertificate record with the new certificate.
|
|
56
|
+
*
|
|
57
|
+
* @param request RegenerateInstalledCertificateSchema
|
|
58
|
+
* @return Promise<InstalledCertificate> - the updated installed certificate record
|
|
59
|
+
*/
|
|
60
|
+
regenerateExistingCertificate(request: FastifyRequest<{
|
|
61
|
+
Body: RegenerateExistingCertificate;
|
|
62
|
+
Querystring: IMessageQuerystring;
|
|
63
|
+
}>): Promise<InstalledCertificate>;
|
|
64
|
+
/**
|
|
65
|
+
* Overrides superclass method to generate the URL path based on the input {@link Namespace}
|
|
66
|
+
* and the module's endpoint prefix configuration.
|
|
67
|
+
*
|
|
68
|
+
* @param {Namespace} input - The input {@link Namespace}.
|
|
69
|
+
* @return {string} - The generated URL path.
|
|
70
|
+
*/
|
|
71
|
+
protected _toDataPath(input: OCPP2_0_1_Namespace | OCPP1_6_Namespace | Namespace): string;
|
|
72
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
// SPDX-FileCopyrightText: 2025 Contributors to the CitrineOS Project
|
|
11
|
+
//
|
|
12
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
13
|
+
import { AbstractModuleApi, AsDataEndpoint, DEFAULT_TENANT_ID, HttpMethod, IMessageQuerystringSchema, Namespace, OCPP1_6_Namespace, OCPP2_0_1, OCPP2_0_1_CallAction, OCPP2_0_1_Namespace, OCPPVersion, } from '@citrineos/base';
|
|
14
|
+
import { Certificate, CountryNameEnumType, GenerateCertificateChainRequest, GenerateCertificateChainSchema, InstalledCertificate, InstallRootCertificateRequest, InstallRootCertificateSchema, RegenerateExistingCertificate, RegenerateInstalledCertificateSchema, SignatureAlgorithmEnumType, TenantQuerySchema, TlsCertificateSchema, TlsCertificatesRequest, UpdateTlsCertificateQuerySchema, UploadExistingCertificate, UploadExistingCertificateSchema, } from '@citrineos/data';
|
|
15
|
+
import { generateCertificate } from '@citrineos/util';
|
|
16
|
+
import jsrsasign from 'jsrsasign';
|
|
17
|
+
import moment from 'moment';
|
|
18
|
+
import { Logger } from 'tslog';
|
|
19
|
+
import { CertificatesModule } from './module.js';
|
|
20
|
+
import { PemType } from './installCertificateHelperService.js';
|
|
21
|
+
/**
|
|
22
|
+
* Server API for the Certificates module.
|
|
23
|
+
*/
|
|
24
|
+
export class CertificatesDataApi extends AbstractModuleApi {
|
|
25
|
+
_websocketServersConfig;
|
|
26
|
+
_fileStorage;
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a new instance of the class.
|
|
29
|
+
*
|
|
30
|
+
* @param {CertificatesModule} certificatesModule - The Certificates module.
|
|
31
|
+
* @param {FastifyInstance} server - The Fastify server instance.
|
|
32
|
+
* @param {IFileStorage} fileStorage - The fileStorage
|
|
33
|
+
* @param {WebsocketServerConfig[]} websocketServersConfig - Configuration for websocket servers
|
|
34
|
+
* @param {Logger<ILogObj>} [logger] - The logger instance.
|
|
35
|
+
*/
|
|
36
|
+
constructor(certificatesModule, server, fileStorage, websocketServersConfig, logger) {
|
|
37
|
+
super(certificatesModule, server, OCPPVersion.OCPP2_0_1, logger);
|
|
38
|
+
this._fileStorage = fileStorage;
|
|
39
|
+
this._websocketServersConfig = websocketServersConfig;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Data Endpoint Methods
|
|
43
|
+
*/
|
|
44
|
+
async putTlsCertificates(request) {
|
|
45
|
+
const serverId = request.query.id;
|
|
46
|
+
this._logger.info(`Receive update TLS certificates request for server ${serverId}`);
|
|
47
|
+
const certRequest = request.body;
|
|
48
|
+
const serverConfig = this._websocketServersConfig.find((config) => config.id === serverId);
|
|
49
|
+
if (!serverConfig) {
|
|
50
|
+
throw new Error(`websocketServer id ${serverId} does not exist.`);
|
|
51
|
+
}
|
|
52
|
+
else if (serverConfig && serverConfig.securityProfile < 2) {
|
|
53
|
+
throw new Error(`websocketServer ${serverId} is not tls or mtls server.`);
|
|
54
|
+
}
|
|
55
|
+
else if (serverConfig.securityProfile === 3 && !certRequest.subCAKey) {
|
|
56
|
+
throw new Error(`WebsocketServer ${serverId} is mtls server but subCAKey is missing.`);
|
|
57
|
+
}
|
|
58
|
+
const tlsKey = (await this._fileStorage.getFile(certRequest.privateKey)).toString();
|
|
59
|
+
let tlsCertificateChain = '';
|
|
60
|
+
for (const fileId of certRequest.certificateChain) {
|
|
61
|
+
tlsCertificateChain += (await this._fileStorage.getFile(fileId)).toString();
|
|
62
|
+
}
|
|
63
|
+
const rootCA = certRequest.rootCA
|
|
64
|
+
? (await this._fileStorage.getFile(certRequest.rootCA)).toString()
|
|
65
|
+
: undefined;
|
|
66
|
+
const subCAKey = certRequest.subCAKey
|
|
67
|
+
? (await this._fileStorage.getFile(certRequest.subCAKey)).toString()
|
|
68
|
+
: undefined;
|
|
69
|
+
this._module.installCertificateHelperService.updateCertificates(serverConfig, serverId, tlsKey, tlsCertificateChain, subCAKey, rootCA);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* This endpoint is used to create certificate chain, root CA, sub CA and leaf certificate
|
|
73
|
+
*
|
|
74
|
+
* @param request - GenerateRootCertificatesRequest
|
|
75
|
+
* @return Promise<Certificate[]> - An array of generated certificates
|
|
76
|
+
*/
|
|
77
|
+
async generateCertificateChain(request) {
|
|
78
|
+
this._logger.info(`Receiving generate certificate chain request ${JSON.stringify(request.body)}`);
|
|
79
|
+
const tenantId = request.query.tenantId;
|
|
80
|
+
const certRequest = request.body;
|
|
81
|
+
let certificateFromReq = new Certificate();
|
|
82
|
+
certificateFromReq.serialNumber = moment().valueOf();
|
|
83
|
+
certificateFromReq.keyLength = certRequest.keyLength ? certRequest.keyLength : 2048;
|
|
84
|
+
certificateFromReq.organizationName = certRequest.organizationName;
|
|
85
|
+
certificateFromReq.commonName = certRequest.commonName + ` ${PemType.Root}`;
|
|
86
|
+
if (certRequest.validBefore) {
|
|
87
|
+
certificateFromReq.validBefore = certRequest.validBefore;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const defaultValidityDate = new Date();
|
|
91
|
+
defaultValidityDate.setFullYear(defaultValidityDate.getFullYear() + 1);
|
|
92
|
+
certificateFromReq.validBefore = defaultValidityDate.toISOString();
|
|
93
|
+
}
|
|
94
|
+
certificateFromReq.countryName = certRequest.countryName
|
|
95
|
+
? certRequest.countryName
|
|
96
|
+
: CountryNameEnumType.US;
|
|
97
|
+
certificateFromReq.signatureAlgorithm = certRequest.signatureAlgorithm
|
|
98
|
+
? certRequest.signatureAlgorithm
|
|
99
|
+
: SignatureAlgorithmEnumType.ECDSA;
|
|
100
|
+
certificateFromReq.isCA = true;
|
|
101
|
+
certificateFromReq.pathLen = certRequest.pathLen ? certRequest.pathLen : 1;
|
|
102
|
+
let responseBody;
|
|
103
|
+
if (certRequest.selfSigned) {
|
|
104
|
+
// Generate self-signed root CA certificate
|
|
105
|
+
const [rootCertificatePem, rootPrivateKeyPem] = generateCertificate(certificateFromReq, this._logger);
|
|
106
|
+
certificateFromReq =
|
|
107
|
+
await this._module.installCertificateHelperService.storeCertificateAndKey(tenantId, certificateFromReq, rootCertificatePem, rootPrivateKeyPem, PemType.Root, certRequest.filePath);
|
|
108
|
+
// Generate sub CA certificate
|
|
109
|
+
let subCertificate = new Certificate();
|
|
110
|
+
subCertificate.serialNumber = certificateFromReq.serialNumber + 1;
|
|
111
|
+
subCertificate.keyLength = certificateFromReq.keyLength;
|
|
112
|
+
subCertificate.organizationName = certificateFromReq.organizationName;
|
|
113
|
+
subCertificate.commonName = certRequest.commonName + ` ${PemType.SubCA}`;
|
|
114
|
+
subCertificate.validBefore = certificateFromReq.validBefore;
|
|
115
|
+
subCertificate.signedBy = certificateFromReq.id;
|
|
116
|
+
subCertificate.countryName = certificateFromReq.countryName;
|
|
117
|
+
subCertificate.signatureAlgorithm = certificateFromReq.signatureAlgorithm;
|
|
118
|
+
subCertificate.isCA = true;
|
|
119
|
+
subCertificate.pathLen = 0;
|
|
120
|
+
const [subCertificatePem, subPrivateKeyPem] = generateCertificate(subCertificate, this._logger, rootPrivateKeyPem, rootCertificatePem);
|
|
121
|
+
subCertificate = await this._module.installCertificateHelperService.storeCertificateAndKey(tenantId, subCertificate, subCertificatePem, subPrivateKeyPem, PemType.SubCA, certRequest.filePath);
|
|
122
|
+
// Generate leaf certificate
|
|
123
|
+
let leafCertificate = new Certificate();
|
|
124
|
+
leafCertificate.serialNumber = subCertificate.serialNumber + 1;
|
|
125
|
+
leafCertificate.keyLength = subCertificate.keyLength;
|
|
126
|
+
leafCertificate.organizationName = subCertificate.organizationName;
|
|
127
|
+
leafCertificate.commonName = certRequest.commonName;
|
|
128
|
+
leafCertificate.validBefore = subCertificate.validBefore;
|
|
129
|
+
leafCertificate.signedBy = subCertificate.id;
|
|
130
|
+
leafCertificate.countryName = subCertificate.countryName;
|
|
131
|
+
leafCertificate.signatureAlgorithm = subCertificate.signatureAlgorithm;
|
|
132
|
+
leafCertificate.isCA = false;
|
|
133
|
+
const [leafCertificatePem, leafPrivateKeyPem] = generateCertificate(leafCertificate, this._logger, subPrivateKeyPem, subCertificatePem);
|
|
134
|
+
leafCertificate = await this._module.installCertificateHelperService.storeCertificateAndKey(tenantId, leafCertificate, leafCertificatePem, leafPrivateKeyPem, PemType.Leaf, certRequest.filePath);
|
|
135
|
+
responseBody = [leafCertificate, subCertificate, certificateFromReq];
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Generate sub CA certificate and private key signed by external CA server
|
|
139
|
+
// commonName should be a valid domain name
|
|
140
|
+
certificateFromReq.commonName = certRequest.commonName;
|
|
141
|
+
certificateFromReq.pathLen = 0;
|
|
142
|
+
const [certificatePem, privateKeyPem] = await this._module.installCertificateHelperService.generateSubCACertificateSignedByCAServer(certificateFromReq);
|
|
143
|
+
certificateFromReq =
|
|
144
|
+
await this._module.installCertificateHelperService.storeCertificateAndKey(tenantId, certificateFromReq, certificatePem, privateKeyPem, PemType.SubCA, certRequest.filePath);
|
|
145
|
+
// Generate leaf certificate
|
|
146
|
+
let leafCertificate = new Certificate();
|
|
147
|
+
leafCertificate.serialNumber = certificateFromReq.serialNumber + 1;
|
|
148
|
+
leafCertificate.keyLength = certificateFromReq.keyLength;
|
|
149
|
+
leafCertificate.organizationName = certificateFromReq.organizationName;
|
|
150
|
+
leafCertificate.commonName = certRequest.commonName;
|
|
151
|
+
leafCertificate.validBefore = certificateFromReq.validBefore;
|
|
152
|
+
leafCertificate.signedBy = certificateFromReq.id;
|
|
153
|
+
leafCertificate.countryName = certificateFromReq.countryName;
|
|
154
|
+
leafCertificate.signatureAlgorithm = certificateFromReq.signatureAlgorithm;
|
|
155
|
+
leafCertificate.isCA = false;
|
|
156
|
+
leafCertificate.pathLen = undefined;
|
|
157
|
+
const [leafCertificatePem, leafPrivateKeyPem] = generateCertificate(leafCertificate, this._logger, privateKeyPem, certificatePem);
|
|
158
|
+
leafCertificate = await this._module.installCertificateHelperService.storeCertificateAndKey(tenantId, leafCertificate, leafCertificatePem, leafPrivateKeyPem, PemType.Leaf, certRequest.filePath);
|
|
159
|
+
responseBody = [leafCertificate, certificateFromReq];
|
|
160
|
+
}
|
|
161
|
+
return responseBody;
|
|
162
|
+
}
|
|
163
|
+
async installRootCertificate(request) {
|
|
164
|
+
const installReq = request.body;
|
|
165
|
+
this._logger.info(`Installing ${installReq.certificateType} on charger ${installReq.stationId}`);
|
|
166
|
+
let rootCAPem;
|
|
167
|
+
if (installReq.fileId) {
|
|
168
|
+
rootCAPem = (await this._fileStorage.getFile(installReq.fileId)).toString();
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
rootCAPem = await this._module.certificateAuthorityService.getRootCACertificateFromExternalCA(installReq.certificateType);
|
|
172
|
+
}
|
|
173
|
+
await this._module
|
|
174
|
+
.sendCall(installReq.stationId, installReq.tenantId, OCPPVersion.OCPP2_0_1, OCPP2_0_1_CallAction.InstallCertificate, {
|
|
175
|
+
certificateType: installReq.certificateType,
|
|
176
|
+
certificate: rootCAPem,
|
|
177
|
+
}, installReq.callbackUrl)
|
|
178
|
+
.then((confirmation) => {
|
|
179
|
+
if (!confirmation.success) {
|
|
180
|
+
throw new Error(`Send InstallCertificateRequest failed: ${confirmation.payload}`);
|
|
181
|
+
}
|
|
182
|
+
this._logger.debug('InstallCertificate confirmation sent:', confirmation);
|
|
183
|
+
});
|
|
184
|
+
return {
|
|
185
|
+
success: true,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Endpoint to upload an existing certificate that is already installed on a given station to the CSMS
|
|
190
|
+
* @param request - UploadExistingCertificateSchema
|
|
191
|
+
* @return Promise<InstalledCertificate> - the installed certificate record
|
|
192
|
+
*/
|
|
193
|
+
async uploadExistingCertificate(request) {
|
|
194
|
+
const uploadExistingCertificate = request.body;
|
|
195
|
+
const messageQuerystring = request.query;
|
|
196
|
+
const tenantId = messageQuerystring.tenantId || DEFAULT_TENANT_ID;
|
|
197
|
+
const identifier = messageQuerystring.identifier;
|
|
198
|
+
const isIdentifierList = Array.isArray(identifier);
|
|
199
|
+
if (isIdentifierList) {
|
|
200
|
+
const promises = [];
|
|
201
|
+
for (const identifierElement of identifier) {
|
|
202
|
+
promises.push(this._module.installCertificateHelperService.handleUploadExistingCertificate(tenantId, identifierElement, uploadExistingCertificate, request.body.filePath));
|
|
203
|
+
}
|
|
204
|
+
return await Promise.all(promises);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
return [
|
|
208
|
+
await this._module.installCertificateHelperService.handleUploadExistingCertificate(tenantId, identifier, uploadExistingCertificate, request.body.filePath),
|
|
209
|
+
];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Endpoint to regenerate an existing certificate that is already installed on a given station.
|
|
214
|
+
* Updates the InstalledCertificate record with the new certificate.
|
|
215
|
+
*
|
|
216
|
+
* @param request RegenerateInstalledCertificateSchema
|
|
217
|
+
* @return Promise<InstalledCertificate> - the updated installed certificate record
|
|
218
|
+
*/
|
|
219
|
+
async regenerateExistingCertificate(request) {
|
|
220
|
+
const installedCertificateId = request.body.installedCertificateId;
|
|
221
|
+
const validBeforeParam = request.body.validBefore;
|
|
222
|
+
const stationId = request.query.identifier;
|
|
223
|
+
const tenantId = request.query.tenantId || DEFAULT_TENANT_ID;
|
|
224
|
+
this._logger.info(`Regenerating existing certificate ${installedCertificateId} for charger ${stationId}`);
|
|
225
|
+
const existingInstalledCertificate = await this._module.installedCertificateRepository.readOnlyOneByQuery(tenantId, {
|
|
226
|
+
where: {
|
|
227
|
+
id: installedCertificateId,
|
|
228
|
+
stationId: stationId,
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
if (!existingInstalledCertificate) {
|
|
232
|
+
throw new Error('Installed certificate not found');
|
|
233
|
+
}
|
|
234
|
+
const existingCertificateRecord = await existingInstalledCertificate.$get('certificate');
|
|
235
|
+
if (!existingCertificateRecord) {
|
|
236
|
+
throw new Error('Certificate not found');
|
|
237
|
+
}
|
|
238
|
+
const fileId = existingCertificateRecord.certificateFileId;
|
|
239
|
+
if (!fileId) {
|
|
240
|
+
throw new Error('Certificate file not found');
|
|
241
|
+
}
|
|
242
|
+
const privateKeyFileId = existingCertificateRecord.privateKeyFileId;
|
|
243
|
+
if (!privateKeyFileId) {
|
|
244
|
+
throw new Error('Certificate privateKeyFileId not found');
|
|
245
|
+
}
|
|
246
|
+
const existingCertificateBuffer = await this._fileStorage.getFile(fileId);
|
|
247
|
+
const existingPrivateKeyBuffer = await this._fileStorage.getFile(privateKeyFileId);
|
|
248
|
+
if (!existingCertificateBuffer || !existingPrivateKeyBuffer) {
|
|
249
|
+
throw new Error('Certificate files not found');
|
|
250
|
+
}
|
|
251
|
+
const existingCertificateString = existingCertificateBuffer.toString();
|
|
252
|
+
const existingPrivateKey = existingPrivateKeyBuffer.toString();
|
|
253
|
+
const existingCertificate = new jsrsasign.X509();
|
|
254
|
+
existingCertificate.readCertPEM(existingCertificateString);
|
|
255
|
+
const existingSubjectString = existingCertificate.getSubjectString();
|
|
256
|
+
let newCertificateRecord = new Certificate();
|
|
257
|
+
newCertificateRecord.serialNumber = moment().valueOf();
|
|
258
|
+
newCertificateRecord.issuerName = existingSubjectString;
|
|
259
|
+
newCertificateRecord.organizationName = existingCertificateRecord.organizationName;
|
|
260
|
+
newCertificateRecord.commonName = existingCertificateRecord.commonName;
|
|
261
|
+
newCertificateRecord.keyLength = existingCertificateRecord.keyLength;
|
|
262
|
+
newCertificateRecord.validBefore = validBeforeParam;
|
|
263
|
+
newCertificateRecord.signatureAlgorithm = existingCertificateRecord.signatureAlgorithm;
|
|
264
|
+
newCertificateRecord.countryName = existingCertificateRecord.countryName;
|
|
265
|
+
newCertificateRecord.isCA = existingCertificateRecord.isCA;
|
|
266
|
+
newCertificateRecord.pathLen = existingCertificateRecord.pathLen;
|
|
267
|
+
newCertificateRecord.signedBy = existingCertificateRecord.id;
|
|
268
|
+
newCertificateRecord.certificateFileHash = existingCertificateRecord.certificateFileHash;
|
|
269
|
+
const [newCertificatePem, newPrivateKeyPem] = generateCertificate(newCertificateRecord, this._logger, existingPrivateKey, existingCertificateString);
|
|
270
|
+
newCertificateRecord.certificateFileHash =
|
|
271
|
+
this._module.installCertificateHelperService.getCertificateHash(newCertificatePem);
|
|
272
|
+
newCertificateRecord.certificateFileId = await this._fileStorage.saveFile(`Regenerated_Cert_${newCertificateRecord.serialNumber}.pem`, Buffer.from(newCertificatePem));
|
|
273
|
+
newCertificateRecord.privateKeyFileId = await this._fileStorage.saveFile(`Regenerated_Key_${newCertificateRecord.serialNumber}.pem`, Buffer.from(newPrivateKeyPem));
|
|
274
|
+
newCertificateRecord = await newCertificateRecord.save();
|
|
275
|
+
existingInstalledCertificate.certificateId = newCertificateRecord.id;
|
|
276
|
+
await existingInstalledCertificate.save();
|
|
277
|
+
return existingInstalledCertificate;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Overrides superclass method to generate the URL path based on the input {@link Namespace}
|
|
281
|
+
* and the module's endpoint prefix configuration.
|
|
282
|
+
*
|
|
283
|
+
* @param {Namespace} input - The input {@link Namespace}.
|
|
284
|
+
* @return {string} - The generated URL path.
|
|
285
|
+
*/
|
|
286
|
+
_toDataPath(input) {
|
|
287
|
+
const endpointPrefix = this._module.config.modules.certificates?.endpointPrefix;
|
|
288
|
+
return super._toDataPath(input, endpointPrefix);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
__decorate([
|
|
292
|
+
AsDataEndpoint(OCPP2_0_1_Namespace.TlsCertificates, HttpMethod.Put, UpdateTlsCertificateQuerySchema, TlsCertificateSchema),
|
|
293
|
+
__metadata("design:type", Function),
|
|
294
|
+
__metadata("design:paramtypes", [Object]),
|
|
295
|
+
__metadata("design:returntype", Promise)
|
|
296
|
+
], CertificatesDataApi.prototype, "putTlsCertificates", null);
|
|
297
|
+
__decorate([
|
|
298
|
+
AsDataEndpoint(OCPP2_0_1_Namespace.CertificateChain, HttpMethod.Post, TenantQuerySchema, GenerateCertificateChainSchema),
|
|
299
|
+
__metadata("design:type", Function),
|
|
300
|
+
__metadata("design:paramtypes", [Object]),
|
|
301
|
+
__metadata("design:returntype", Promise)
|
|
302
|
+
], CertificatesDataApi.prototype, "generateCertificateChain", null);
|
|
303
|
+
__decorate([
|
|
304
|
+
AsDataEndpoint(OCPP2_0_1_Namespace.RootCertificate, HttpMethod.Put, undefined, InstallRootCertificateSchema),
|
|
305
|
+
__metadata("design:type", Function),
|
|
306
|
+
__metadata("design:paramtypes", [Object]),
|
|
307
|
+
__metadata("design:returntype", Promise)
|
|
308
|
+
], CertificatesDataApi.prototype, "installRootCertificate", null);
|
|
309
|
+
__decorate([
|
|
310
|
+
AsDataEndpoint(OCPP2_0_1_Namespace.UploadExistingCertificate, HttpMethod.Post, IMessageQuerystringSchema, UploadExistingCertificateSchema),
|
|
311
|
+
__metadata("design:type", Function),
|
|
312
|
+
__metadata("design:paramtypes", [Object]),
|
|
313
|
+
__metadata("design:returntype", Promise)
|
|
314
|
+
], CertificatesDataApi.prototype, "uploadExistingCertificate", null);
|
|
315
|
+
__decorate([
|
|
316
|
+
AsDataEndpoint(OCPP2_0_1_Namespace.RegenerateExistingCertificate, HttpMethod.Post, IMessageQuerystringSchema, RegenerateInstalledCertificateSchema),
|
|
317
|
+
__metadata("design:type", Function),
|
|
318
|
+
__metadata("design:paramtypes", [Object]),
|
|
319
|
+
__metadata("design:returntype", Promise)
|
|
320
|
+
], CertificatesDataApi.prototype, "regenerateExistingCertificate", null);
|
|
321
|
+
//# sourceMappingURL=DataApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataApi.js","sourceRoot":"","sources":["../../src/module/DataApi.ts"],"names":[],"mappings":";;;;;;;;;AAAA,qEAAqE;AACrE,EAAE;AACF,sCAAsC;AACtC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,UAAU,EAIV,yBAAyB,EACzB,SAAS,EACT,iBAAiB,EACjB,SAAS,EACT,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,GAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,+BAA+B,EAC/B,8BAA8B,EAC9B,oBAAoB,EACpB,6BAA6B,EAC7B,4BAA4B,EAC5B,6BAA6B,EAC7B,oCAAoC,EACpC,0BAA0B,EAC1B,iBAAiB,EAEjB,oBAAoB,EACpB,sBAAsB,EACtB,+BAA+B,EAE/B,yBAAyB,EACzB,+BAA+B,GAChC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAE/D;;GAEG;AACH,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@
|
|
|
1
|
+
import { Certificate, CountryNameEnumType, type ICertificateRepository, type IDeleteCertificateAttemptRepository, type IInstallCertificateAttemptRepository, type IInstalledCertificateRepository, InstalledCertificate, SignatureAlgorithmEnumType, UploadExistingCertificate } from '@citrineos/data';
|
|
2
|
+
import { type CertificateAuthorityService, WebsocketNetworkConnection } from '@citrineos/util';
|
|
3
|
+
import { type IFileStorage, OCPP2_0_1, type WebsocketServerConfig } from '@citrineos/base';
|
|
4
|
+
import { type ILogObj, Logger } from 'tslog';
|
|
5
|
+
export declare const enum PemType {
|
|
6
|
+
Root = "Root",
|
|
7
|
+
SubCA = "SubCA",
|
|
8
|
+
Leaf = "Leaf"
|
|
9
|
+
}
|
|
10
|
+
export declare class InstallCertificateHelperService {
|
|
11
|
+
protected certificateRepository: ICertificateRepository;
|
|
12
|
+
protected installedCertificateRepository: IInstalledCertificateRepository;
|
|
13
|
+
protected installCertificateAttemptRepository: IInstallCertificateAttemptRepository;
|
|
14
|
+
protected deleteCertificateAttemptRepository: IDeleteCertificateAttemptRepository;
|
|
15
|
+
protected certificateAuthorityService: CertificateAuthorityService;
|
|
16
|
+
protected networkConnection: WebsocketNetworkConnection;
|
|
17
|
+
protected fileStorage: IFileStorage;
|
|
18
|
+
protected logger: Logger<ILogObj>;
|
|
19
|
+
constructor(certificateRepository: ICertificateRepository, installedCertificateRepository: IInstalledCertificateRepository, installCertificateAttemptRepository: IInstallCertificateAttemptRepository, deleteCertificateAttemptRepository: IDeleteCertificateAttemptRepository, certificateAuthorityService: CertificateAuthorityService, networkConnection: WebsocketNetworkConnection, fileStorage: IFileStorage, logger: Logger<ILogObj>);
|
|
20
|
+
prepareToInstallCertificate(tenantId: number, stationId: string, certificate: string, certificateType: OCPP2_0_1.InstallCertificateUseEnumType): Promise<void>;
|
|
21
|
+
finalizeInstalledCertificate(tenantId: number, stationId: string, status: OCPP2_0_1.InstallCertificateStatusEnumType): Promise<void>;
|
|
22
|
+
createNewCertificate(certificate: string, serialNumber: number | null, issuerName: string | null, organizationName: string | null, commonName: string | null, countryName: CountryNameEnumType | null, validBefore: Date | null, signatureAlgorithm: SignatureAlgorithmEnumType | null): Promise<Certificate>;
|
|
23
|
+
handleUploadExistingCertificate(tenantId: number, identifier: string, uploadExistingCertificate: UploadExistingCertificate, filePath?: string): Promise<InstalledCertificate>;
|
|
24
|
+
/**
|
|
25
|
+
* Generates a sub CA certificate signed by a CA server.
|
|
26
|
+
*
|
|
27
|
+
* @param {Certificate} certificate - The certificate information used for generating the root certificate.
|
|
28
|
+
* @return {Promise<[string, string]>} An array containing the signed certificate and the private key.
|
|
29
|
+
*/
|
|
30
|
+
generateSubCACertificateSignedByCAServer(certificate: Certificate): Promise<[string, string]>;
|
|
31
|
+
/**
|
|
32
|
+
* Store certificate in file storage and db.
|
|
33
|
+
* @param certificateEntity certificate to be stored in db
|
|
34
|
+
* @param certPem certificate pem to be stored in file storage
|
|
35
|
+
* @param keyPem private key pem to be stored in file storage
|
|
36
|
+
* @param filePrefix prefix for file name to be stored in file storage
|
|
37
|
+
* @param filePath file path in file storage
|
|
38
|
+
* @return certificate stored in db
|
|
39
|
+
*/
|
|
40
|
+
storeCertificateAndKey(tenantId: number, certificateEntity: Certificate, certPem: string, keyPem: string, filePrefix: PemType, filePath?: string): Promise<Certificate>;
|
|
41
|
+
updateCertificates(serverConfig: WebsocketServerConfig, serverId: string, tlsKey: string, tlsCertificateChain: string, subCAKey?: string, rootCA?: string): void;
|
|
42
|
+
private replaceFile;
|
|
43
|
+
/**
|
|
44
|
+
* Generate a hash (fingerprint) from a certificate PEM string.
|
|
45
|
+
* @param pemString The certificate PEM string.
|
|
46
|
+
* @returns A SHA-256 hash of the certificate's DER encoding.
|
|
47
|
+
*/
|
|
48
|
+
getCertificateHash(pemString: string): string;
|
|
49
|
+
}
|