Skip to content

Commit

Permalink
fix max subject length
Browse files Browse the repository at this point in the history
  • Loading branch information
erossignon committed Feb 7, 2021
1 parent 11f818d commit 9896793
Show file tree
Hide file tree
Showing 9 changed files with 493 additions and 485 deletions.
Expand Up @@ -8,12 +8,12 @@ import { DataType } from "node-opcua-variant";

import { AddressSpace, Namespace, SessionContext, UAObject, UAObjectType } from "../..";
import { UATwoStateDiscrete } from "../../dist/src/data_access/ua_two_state_discrete";
import { generateAddressSpace } from "../../../playground/node_modules/node-opcua/dist";
import { nodesets } from "node-opcua-nodesets";
import { getTempFilename } from "node-opcua-debug/nodeJS";
import { CallbackT, StatusCode, StatusCodes } from "node-opcua-status-code";
import { DataValue } from "node-opcua-data-value";
import { getCurrentClock } from "node-opcua-date-time";
import { generateAddressSpace } from "../../source_nodejs";

const doDebug = false;

Expand Down
1 change: 1 addition & 0 deletions packages/node-opcua-certificate-manager/source/index.ts
Expand Up @@ -2,3 +2,4 @@
* @module node-opcua-certificate-manager
*/
export * from "./certificate_manager";
export * from "./make_subject";
@@ -0,0 +1,7 @@
import { OPCUACertificateManager } from "./certificate_manager";

export function makeSubject(applicationName: string, hostname: string) {
const commonName = `${applicationName}@${hostname}`.substr(0, 63);
const dc = `${hostname}`.substr(63);
return `/CN=${commonName}` + `/DC=${dc}` + OPCUACertificateManager.defaultCertificateSubject;
}
6 changes: 3 additions & 3 deletions packages/node-opcua-client/source/private/client_base_impl.ts
Expand Up @@ -58,7 +58,7 @@ import {
OPCUAClientBaseOptions
} from "../client_base";
import { ClientSessionImpl } from "./client_session_impl";
import { getDefaultCertificateManager, OPCUACertificateManager } from "node-opcua-certificate-manager";
import { getDefaultCertificateManager, makeSubject, OPCUACertificateManager } from "node-opcua-certificate-manager";
import { performCertificateSanityCheck } from "../verify";
import { VerificationStatus } from "node-opcua-pki";

Expand Down Expand Up @@ -632,13 +632,13 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
const applicationUri: string = this._getBuiltApplicationUri();
const hostname = getHostname();
// this.serverInfo.applicationUri!;

await this.clientCertificateManager.createSelfSignedCertificate({
applicationUri,
dns: [hostname],
// ip: await getIpAddresses(),
outputFile: this.certificateFile,
subject:
`/CN=${applicationName}@${hostname}` + `/DC=${hostname}` + OPCUACertificateManager.defaultCertificateSubject,
subject: makeSubject(applicationName, hostname),

startDate: new Date(),
validity: 365 * 10 // 10 years
Expand Down
Expand Up @@ -883,10 +883,10 @@ export function ClientMonitoredItem_create(
return;
}
ClientMonitoredItemToolbox._toolbox_monitor(subscription, timestampsToReturn, [monitoredItem], (err1?: Error) => {
// if (err1) {
// monitoredItem.emit("err", err1.message);
// monitoredItem.emit("terminated");
// }
if (err1) {
monitoredItem.emit("err", err1.message);
monitoredItem.emit("terminated");
}
if (callback) {
callback(err1, monitoredItem);
}
Expand Down
5 changes: 3 additions & 2 deletions packages/node-opcua-end2end-test/test/discovery/_helper.ts
Expand Up @@ -7,13 +7,15 @@ import {
assert,
ErrorCallback,
makeApplicationUrn,
makeSubject,
OPCUABaseServer,
OPCUACertificateManager,
OPCUADiscoveryServer,
OPCUAServer,
RegisterServerMethod
} from "node-opcua";
import { make_debugLog, checkDebugFlag } from "node-opcua-debug";

const debugLog = make_debugLog("TEST");
const doDebug = checkDebugFlag("TEST");

Expand Down Expand Up @@ -58,8 +60,7 @@ export async function createServerThatRegisterWithDiscoveryServer(
// dns: argv.alternateHostname ? [argv.alternateHostname, fqdn] : [fqdn],
// ip: await getIpAddresses(),
outputFile: certificateFile,
subject: `/CN=${applicationName}@${os.hostname()}/DC=NodeOPCUA-LocalDiscoveryServer`,

subject: makeSubject(applicationName, os.hostname()),
startDate: new Date(),
validity: 365 * 10
});
Expand Down

0 comments on commit 9896793

Please sign in to comment.