Skip to content

Commit 6e958f6

Browse files
[backend] Improve license management supporting official OIDs and grace period (#13840)
1 parent a519ddc commit 6e958f6

File tree

1 file changed

+17
-9
lines changed
  • opencti-platform/opencti-graphql/src/modules/settings

1 file changed

+17
-9
lines changed

opencti-platform/opencti-graphql/src/modules/settings/licensing.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,20 @@ export const IS_LTS_PLATFORM = PLATFORM_VERSION.includes('lts');
2626

2727
// https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers
2828
// 62944 - Filigran
29-
export const LICENSE_OPTION_TYPE = '6.2.9.4.4.10';
30-
export const LICENSE_OPTION_PRODUCT = '6.2.9.4.4.20';
31-
export const LICENSE_OPTION_CREATOR = '6.2.9.4.4.30';
29+
export const LICENSE_OID_TYPE = '1.3.6.1.4.1.62944.10';
30+
export const LICENSE_OID_PRODUCT = '1.3.6.1.4.1.62944.20';
31+
export const LICENSE_OID_CREATOR = '1.3.6.1.4.1.62944.30';
32+
// Legacy OIDs
33+
export const LICENSE_LEGACY_TYPE = '6.2.9.4.4.10';
34+
export const LICENSE_LEGACY_PRODUCT = '6.2.9.4.4.20';
35+
export const LICENSE_LEGACY_CREATOR = '6.2.9.4.4.30';
3236

33-
const getExtensionValue = (clientCrt, extension) => {
34-
return clientCrt.extensions.find((ext) => ext.id === extension)?.value;
37+
const getExtensionValue = (clientCrt, standardOid, legacyOid) => {
38+
const extStandard = clientCrt.extensions.find((ext) => ext.id === standardOid);
39+
if (extStandard) {
40+
return extStandard.value;
41+
}
42+
return clientCrt.extensions.find((ext) => ext.id === legacyOid)?.value;
3543
};
3644

3745
export const getEnterpriseEditionActivePem = (rawPem) => {
@@ -47,10 +55,10 @@ export const getEnterpriseEditionInfoFromPem = (platformInstanceId, rawPem) => {
4755
try {
4856
const clientCrt = forge.pki.certificateFromPem(pem);
4957
const license_valid_cert = OPENCTI_CA.verify(clientCrt);
50-
const license_type = getExtensionValue(clientCrt, LICENSE_OPTION_TYPE);
58+
const license_type = getExtensionValue(clientCrt, LICENSE_OID_TYPE, LICENSE_LEGACY_TYPE);
5159
const valid_type = IS_LTS_PLATFORM ? license_type === LICENSE_OPTION_LTS : true;
52-
const license_creator = getExtensionValue(clientCrt, LICENSE_OPTION_CREATOR);
53-
const valid_product = getExtensionValue(clientCrt, LICENSE_OPTION_PRODUCT) === 'opencti';
60+
const license_creator = getExtensionValue(clientCrt, LICENSE_OID_CREATOR, LICENSE_LEGACY_CREATOR);
61+
const valid_product = getExtensionValue(clientCrt, LICENSE_OID_PRODUCT, LICENSE_LEGACY_PRODUCT) === 'opencti';
5462
const license_customer = clientCrt.subject.getField('O').value;
5563
const license_platform = clientCrt.subject.getField('OU').value;
5664
const license_platform_match = valid_product && valid_type && (license_platform === GLOBAL_LICENSE_OPTION || platformInstanceId === license_platform);
@@ -66,7 +74,7 @@ export const getEnterpriseEditionInfoFromPem = (platformInstanceId, rawPem) => {
6674
// If trial license, deactivation for expiration is direct
6775
if (license_type !== LICENSE_OPTION_TRIAL) {
6876
// If standard or lts license, a 3 months safe period is granted
69-
const license_extra_expiration_date = utcDate(clientCrt.validity.notBefore).add(3, 'months');
77+
const license_extra_expiration_date = utcDate(clientCrt.validity.notAfter).add(3, 'months');
7078
license_extra_expiration_days = license_extra_expiration_date.diff(utcDate(), 'days');
7179
license_extra_expiration = new Date() < license_extra_expiration_date.toDate();
7280
license_validated = license_extra_expiration;

0 commit comments

Comments
 (0)