diff --git a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/plugin-ledger-connector-corda.ts b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/plugin-ledger-connector-corda.ts index 5796a889a0f..9b8eb9eed83 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/plugin-ledger-connector-corda.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/main/typescript/plugin-ledger-connector-corda.ts @@ -45,6 +45,8 @@ import { DiagnoseNodeEndpointV1, } from "./web-services/diagnose-node-endpoint-v1"; +import fs from "fs"; + export interface IPluginLedgerConnectorCordaOptions extends ICactusPluginOptions { logLevel?: LogLevelDesc; @@ -54,6 +56,7 @@ export interface IPluginLedgerConnectorCordaOptions cordaStartCmd?: string; cordaStopCmd?: string; apiUrl?: string; + privateKeyPath?: string; } export class PluginLedgerConnectorCorda @@ -91,6 +94,8 @@ export class PluginLedgerConnectorCorda `${fnTag} options.prometheusExporter`, ); this.prometheusExporter.startMetricsCollection(); + // if privateKeyPath exists, overwrite privateKey in sshConfigAdminShell + this.readPrivateKey(); } public getOpenApiSpec(): unknown { @@ -146,6 +151,14 @@ export class PluginLedgerConnectorCorda return webServices; } + private readPrivateKey(): void { + const { privateKeyPath } = this.options; + if (privateKeyPath) { + const fileContent = fs.readFileSync(privateKeyPath, "utf-8").toString(); + this.options.sshConfigAdminShell.privateKey = fileContent; + } + } + public async getOrCreateWebServices(): Promise { if (Array.isArray(this.endpoints)) { return this.endpoints;