Skip to content

Commit

Permalink
Merge pull request #59 from splunk/volodyad-connect-gateway-fix
Browse files Browse the repository at this point in the history
Set tlsOptions only when defined
  • Loading branch information
Ryan Moore committed Oct 7, 2020
2 parents 283e207 + 5f9ba6d commit 955c2a3
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Running the Fabric Logger in Docker is recommended. A sample docker-compose entr
services:
fabric-logger.example.com:
container_name: fabric-logger.example.com
image: splunkdlt/fabric-logger:release-3.0.0
image: splunkdlt/fabric-logger:release-3.0.1
environment:
- FABRIC_KEYFILE=<path to private key file>
- FABRIC_CERTFILE=<path to signed certificate>
Expand Down Expand Up @@ -107,8 +107,8 @@ We also include a helm chart for Kubernetes deployments. First set your `values.

Alternatively, if you are using `cryptogen` to generate identities, the helm chart can auto-populate secrets for you. You will need to download the helm file and untar it locally so you can copy your `crypto-config` into the director.

wget https://github.com/splunk/fabric-logger/releases/download/3.0.0/fabric-logger-helm-v3.0.0.tgz
tar -xf fabric-logger-helm-v3.0.0.tgz
wget https://github.com/splunk/fabric-logger/releases/download/3.0.1/fabric-logger-helm-v3.0.1.tgz
tar -xf fabric-logger-helm-v3.0.1.tgz
cp -R crypto-config fabric-logger/crypto-config

Set the secrets section of `values.yaml` to:
Expand Down Expand Up @@ -139,7 +139,7 @@ A `network.yaml` configmap will automatically be generated using the secrets and

helm install -n fabric-logger-${PEER_NAME}-${NS} --namespace ${NS} \
-f values.yaml -f network.yaml \
https://github.com/splunk/fabric-logger/releases/download/v3.0.0/fabric-logger-helm-v3.0.0.tgz
https://github.com/splunk/fabric-logger/releases/download/v3.0.1/fabric-logger-helm-v3.0.1.tgz

### Kubernetes: Deleting Helm Chart

Expand Down
4 changes: 2 additions & 2 deletions helm-chart/fabric-logger/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v1
appVersion: "v3.0.0"
appVersion: "v3.0.1"
description: A Helm chart for Splunk Connect for Hyperledger Fabric
name: fabric-logger
version: v3.0.0
version: v3.0.1
keywords:
- blockchain
- hyperledger
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/fabric-logger/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replicaCount: 1

image:
repository: splunkdlt/fabric-logger
tag: release-3.0.0
tag: release-3.0.1
pullPolicy: IfNotPresent

nameOverride: ""
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fabric-logger",
"version": "3.0.0",
"version": "3.0.1",
"description": "Hyperledger Fabric Splunk integration",
"author": "splunk <blockchain@splunk.com>",
"main": "lib/index.js",
Expand Down
48 changes: 26 additions & 22 deletions src/fabric.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,37 @@ export class FabricListener implements ManagedResource {
const connectionProfileYaml = await readFile(this.config.networkConfig, { encoding: 'utf-8' });
const connectionProfile = safeLoad(connectionProfileYaml);
const wallet = await Wallets.newInMemoryWallet();

const cert = await readFile(this.config.certFile, { encoding: 'utf-8' });
const key = await readFile(this.config.keyFile, { encoding: 'utf-8' });
const identity: X509Identity = {
credentials: {
certificate: cert,
privateKey: key,
},
mspId: this.config.msp,
type: 'X.509',
};

wallet.put(this.config.user, identity);

const gatewayOptions: GatewayOptions = {
identity: identity,
wallet,
discovery: { enabled: this.config.discovery, asLocalhost: this.config.asLocalHost },
};

if (this.config.clientCertFile && this.config.clientKeyFile) {
const clientKey = await readFile(this.config.clientKeyFile, { encoding: 'utf-8' });
const clientCert = await readFile(this.config.clientCertFile, { encoding: 'utf-8' });
const cert = await readFile(this.config.certFile, { encoding: 'utf-8' });
const key = await readFile(this.config.keyFile, { encoding: 'utf-8' });
const identity: X509Identity = {
credentials: {
certificate: cert,
privateKey: key,
},
mspId: this.config.msp,
type: 'X.509',
};

wallet.put(this.config.user, identity);
const gatewayOptions: GatewayOptions = {
identity: identity,
wallet,
discovery: { enabled: this.config.discovery, asLocalhost: this.config.asLocalHost },
tlsInfo: {
certificate: clientCert,
key: clientKey,
},
gatewayOptions.tlsInfo = {
certificate: clientCert,
key: clientKey,
};
await this.gateway.connect(connectionProfile, gatewayOptions);
info('Finished Connecting to gateway');
}

await this.gateway.connect(connectionProfile, gatewayOptions);
info('Finished Connecting to gateway');
}

public async listen(): Promise<void> {
Expand Down

0 comments on commit 955c2a3

Please sign in to comment.