node-opcua-certificate-manager
Advanced tools
Comparing version 2.6.0-alpha.7 to 2.6.1
@@ -10,2 +10,7 @@ import { Certificate } from "node-opcua-crypto"; | ||
checkCertificate(certificate: Certificate, callback: StatusCodeCallback): void; | ||
/** | ||
* | ||
* @param certificate | ||
* @param callback | ||
*/ | ||
trustCertificate(certificate: Certificate, callback: (err?: Error | null) => void): void; | ||
@@ -17,4 +22,13 @@ trustCertificate(certificate: Certificate): Promise<void>; | ||
export interface OPCUACertificateManagerOptions { | ||
/** | ||
* where to store the PKI | ||
* default %APPDATA%/node-opcua | ||
*/ | ||
rootFolder?: null | string; | ||
automaticallyAcceptUnknownCertificate?: boolean; | ||
/** | ||
* the name of the pki store( default value = "pki" ) | ||
* | ||
* the PKI folder will be <rootFolder>/<name> | ||
*/ | ||
name?: string; | ||
@@ -21,0 +35,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.checkCertificateValidity = exports.OPCUACertificateManager = void 0; | ||
/** | ||
* @module node-opcua-certificate-manager | ||
*/ | ||
// tslint:disable:no-empty | ||
const chalk = require("chalk"); | ||
@@ -17,2 +21,3 @@ const fs = require("fs"); | ||
class OPCUACertificateManager extends node_opcua_pki_1.CertificateManager { | ||
/* */ | ||
constructor(options) { | ||
@@ -53,2 +58,3 @@ options = options || {}; | ||
const thumbprint = node_opcua_crypto_1.makeSHA1Thumbprint(certificate).toString("hex"); | ||
// certificate has not bee seen before | ||
errorLog("Certificate with thumbprint " + thumbprint + "has not been seen before"); | ||
@@ -78,2 +84,4 @@ if (this.automaticallyAcceptUnknownCertificate) { | ||
exports.OPCUACertificateManager = OPCUACertificateManager; | ||
// tslint:disable:no-var-requires | ||
// tslint:disable:max-line-length | ||
const thenify = require("thenify"); | ||
@@ -85,9 +93,19 @@ const opts = { multiArgs: false }; | ||
thenify.withCallback(OPCUACertificateManager.prototype.getTrustStatus, opts); | ||
// also see OPCUA 1.02 part 4 : | ||
// - page 95 6.1.3 Determining if a Certificate is Trusted | ||
// - page 100 6.2.3 Validating a Software Certificate | ||
// | ||
function checkCertificateValidity(certificate) { | ||
// Is the signature on the SoftwareCertificate valid .? | ||
if (!certificate) { | ||
// missing certificate | ||
return node_opcua_status_code_1.StatusCodes.BadSecurityChecksFailed; | ||
} | ||
// Has SoftwareCertificate passed its issue date and has it not expired ? | ||
// check dates | ||
const cert = node_opcua_crypto_1.exploreCertificateInfo(certificate); | ||
const now = new Date(); | ||
if (cert.notBefore.getTime() > now.getTime()) { | ||
// certificate is not active yet | ||
// tslint:disable-next-line:no-console | ||
console.log(chalk.red(" Sender certificate is invalid : certificate is not active yet !") + | ||
@@ -98,2 +116,4 @@ " not before date =" + cert.notBefore); | ||
if (cert.notAfter.getTime() <= now.getTime()) { | ||
// certificate is obsolete | ||
// tslint:disable-next-line:no-console | ||
console.log(chalk.red(" Sender certificate is invalid : certificate has expired !") + | ||
@@ -103,2 +123,11 @@ " not after date =" + cert.notAfter); | ||
} | ||
// Has SoftwareCertificate has been revoked by the issuer ? | ||
// TODO: check if certificate is revoked or not ... | ||
// StatusCodes.BadCertificateRevoked | ||
// is issuer Certificate valid and has not been revoked by the CA that issued it. ? | ||
// TODO : check validity of issuer certificate | ||
// StatusCodes.BadCertificateIssuerRevoked | ||
// does the URI specified in the ApplicationDescription match the URI in the Certificate ? | ||
// TODO : check ApplicationDescription of issuer certificate | ||
// return StatusCodes.BadCertificateUriInvalid | ||
return node_opcua_status_code_1.StatusCodes.Good; | ||
@@ -105,0 +134,0 @@ } |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module node-opcua-certificate-manager | ||
*/ | ||
export * from "./certificate_manager"; |
@@ -13,3 +13,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module node-opcua-certificate-manager | ||
*/ | ||
__exportStar(require("./certificate_manager"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "node-opcua-certificate-manager", | ||
"version": "2.6.0-alpha.7", | ||
"version": "2.6.1", | ||
"description": "pure nodejs OPCUA SDK - module -client", | ||
@@ -24,12 +24,12 @@ "scripts": { | ||
"mkdirp": "0.5.5", | ||
"node-opcua-assert": "^2.6.0-alpha.1", | ||
"node-opcua-basic-types": "^2.6.0-alpha.1", | ||
"node-opcua-buffer-utils": "^2.6.0-alpha.1", | ||
"node-opcua-common": "^2.6.0-alpha.7", | ||
"node-opcua-constants": "^2.6.0-alpha.1", | ||
"node-opcua-assert": "^2.6.1", | ||
"node-opcua-basic-types": "^2.6.1", | ||
"node-opcua-buffer-utils": "^2.6.1", | ||
"node-opcua-common": "^2.6.1", | ||
"node-opcua-constants": "^2.6.1", | ||
"node-opcua-crypto": "^1.3.2", | ||
"node-opcua-debug": "^2.6.0-alpha.1", | ||
"node-opcua-debug": "^2.6.1", | ||
"node-opcua-pki": "^2.0.2", | ||
"node-opcua-status-code": "^2.6.0-alpha.1", | ||
"node-opcua-utils": "^2.6.0-alpha.1", | ||
"node-opcua-status-code": "^2.6.1", | ||
"node-opcua-utils": "^2.6.1", | ||
"once": "^1.4.0", | ||
@@ -43,3 +43,3 @@ "thenify": "^3.3.0", | ||
"dequeue": "^1.0.5", | ||
"node-opcua-leak-detector": "^2.6.0-alpha.1", | ||
"node-opcua-leak-detector": "^2.6.1", | ||
"should": "^13.2.3", | ||
@@ -68,3 +68,3 @@ "sinon": "^9.0.2" | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "6af0c6f183dcb96ddc5a2befc98851d0960c5fd0" | ||
"gitHead": "15f0c0f83232fc63310dc04fea187048c7a01e4b" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
24596
405
0
Updatednode-opcua-assert@^2.6.1
Updatednode-opcua-common@^2.6.1
Updatednode-opcua-constants@^2.6.1
Updatednode-opcua-debug@^2.6.1
Updatednode-opcua-utils@^2.6.1