MCPcopy
hub / github.com/vpulim/node-soap / ClientSSLSecurity

Class ClientSSLSecurity

src/security/ClientSSLSecurity.ts:16–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 * @constructor
15 */
16export class ClientSSLSecurity implements ISecurity {
17 private key: Buffer;
18 private cert: Buffer;
19 private ca;
20 private defaults;
21 private agent: https.Agent;
22
23 constructor(key: string | Buffer, cert: string | Buffer, ca?: Buffer | string | any[] | any, defaults?: any) {
24 if (key) {
25 if (Buffer.isBuffer(key)) {
26 this.key = key;
27 } else if (typeof key === 'string') {
28 this.key = fs.readFileSync(key);
29 } else {
30 throw new Error('key should be a buffer or a string!');
31 }
32 }
33
34 if (cert) {
35 if (Buffer.isBuffer(cert)) {
36 this.cert = cert;
37 } else if (typeof cert === 'string') {
38 this.cert = fs.readFileSync(cert);
39 } else {
40 throw new Error('cert should be a buffer or a string!');
41 }
42 }
43
44 if (ca) {
45 if (Buffer.isBuffer(ca) || Array.isArray(ca)) {
46 this.ca = ca;
47 } else if (typeof ca === 'string') {
48 this.ca = fs.readFileSync(ca);
49 } else {
50 defaults = ca;
51 this.ca = null;
52 }
53 }
54
55 this.defaults = {};
56 merge(this.defaults, defaults);
57
58 this.agent = null;
59 }
60
61 public toXML(): string {
62 return '';
63 }
64
65 public addOptions(options: any): void {
66 //eslint-disable-next-line no-useless-assignment
67 let httpsAgent = null;
68
69 options.key = this.key;
70 options.cert = this.cert;
71 options.ca = this.ca;
72 merge(options, this.defaults);
73

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected