Fabric SDK unable to initialize cryptosuite config - go

I'm running a business network on IBM Cloud Blockchain Platform 2.0. I downloaded a connection profile from the instantiated smart contracts section on the Platform Console, and am trying to connect using the Fabric SDK for Go but I am facing an error.
This is my current relevant code, under main
configOpts := fabricConfig.FromFile("./profiles/flex.json")
fabSDK, err := fabsdk.New(configOpts)
if err != nil {
entry.WithError(err).Fatal("Error setting up Fabric SDK")
}
defer fabSDK.Close()
Expected: Connects to the business network instance
Actual: I get an error
FATA[0000] Error setting up Fabric SDK env=DEV
error="failed to initialize configuration: unable to initialize cryptosuite using crypto suite config:
failed to initialize crypto suite: Unsupported BCCSP Provider: "

I add "cryptoconfig" path to the client.
BCCSP is optional, and you can remove.
I added the sample config, please see below.
More detail config at Github go-SDK config.yaml
{
"name": "first-network-org1",
"version": "1.0.0",
"client": {
"organization": "Org1",
"logging": {
"level": "info"
},
"cryptoconfig": {
"path": "crypto-config"
},
"credentialStore": {
"path": "/tmp/keystore",
"cryptoStore": {
"path": "/tmp/msp"
}
},
"connection": {
"timeout": {
"peer": {
"endorser": "300"
}
}
}
},
"channels": {
"mychannel": {
"peers": {
"peer0.org1.example.com": {}
}
}
},
"orderers": {
"orderer.example.com": {
"url": "orderer.example.com:7050",
"grpcOptions": {
"ssl-target-name-override": "orderer.example.com",
"keep-alive-time": "60s",
"keep-alive-timeout": "60s",
"keep-alive-permit": false,
"fail-fast": false,
"allow-insecure": false
},
"tlsCACerts": {
"path": "crypto-config/ordererOrganizations/example.com/tlsca/tlsca.example.com-cert.pem"
}
}
},
"organizations": {
"Org1": {
"mspid": "Org1MSP",
"cryptoPath": "crypto-config/peerOrganizations/org1.example.com/users/User1#org1.example.com/msp",
"peers": [
"peer0.org1.example.com",
"peer1.org1.example.com"
],
"certificateAuthorities": [
"ca.org1.example.com"
]
}
},
"peers": {
"peer0.org1.example.com": {
"url": "grpcs://localhost:7051",
"tlsCACerts": {
"path": "crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem"
},
"grpcOptions": {
"ssl-target-name-override": "peer0.org1.example.com"
}
},
"peer1.org1.example.com": {
"url": "grpcs://localhost:8051",
"tlsCACerts": {
"path": "crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem"
},
"grpcOptions": {
"ssl-target-name-override": "peer1.org1.example.com"
}
}
},
"certificateAuthorities": {
"ca.org1.example.com": {
"url": "https://localhost:7054",
"caName": "ca-org1",
"tlsCACerts": {
"path": "crypto-config/peerOrganizations/org1.example.com/tlsca/tlsca.org1.example.com-cert.pem"
},
"httpOptions": {
"verify": false
}
}
}
}

Related

Unable to start AWSFIS-Run-CPU-Stress

While running AWSFIS-Run-CPU-Stress i am getting below error:
Unable to start action, due to a platform mismatch between the specified document and the targeted instances. I am trying this in Windows EC2 instance
My Experiment script look like this(removed confidential server info):
{
"description": "Test CPU stress predefined SSM document",
"targets": {
"testInstance": {
"resourceType": "aws:ec2:instance",
"resourceArns": [
"arn:aws:ec2:region:123456789012:instance/instance_id"
],
"selectionMode": "ALL"
}
},
"actions": {
"runCpuStress": {
"actionId": "aws:ssm:send-command",
"parameters": {
"documentArn": "arn:aws:ssm:region::document/AWSFIS-Run-CPU-Stress",
"documentParameters": "{\"DurationSeconds\":\"120\"}",
"duration": "PT5M"
},
"targets": {
"Instances": "testInstance"
}
}
},
"stopConditions": [
{
"source": "aws:cloudwatch:alarm",
"value": "arn:aws:cloudwatch:region:123456789012:alarm:awsec2-instance_id-GreaterThanOrEqualToThreshold-CPUUtilization"
}
],
"roleArn": "arn:aws:iam::123456789012:role/AllowFISSSMActions",
"tags": {}
}

INDEXER Lake Framework - outcome.status.failure not showing execution error

The following transaction
https://explorer.near.org/transactions/CkZYiXB3BEoXNuLDqcn5GjErkXghKGCB47yPyyze4kTf#BPYU8T3o5mdsU4ewG3JdCLRe8ivpsGTehKxkifFAsboD
failed whith the following error:
{
"type": "action",
"error": {
"type": "functionCallError",
"error": {
"type": "executionError",
"error": "Smart contract panicked: The contract is not initialized"
}
}
}
But what I got on the indexer is the following:
{
"outcome":{
"executionOutcome":{
"blockHash":"8NP4Z2i7CBQzRUxa8CfuummnYZvwfZaCFmif4d6mcgyB",
"id":"CkZYiXB3BEoXNuLDqcn5GjErkXghKGCB47yPyyze4kTf",
"outcome":{
"executorId":"test1.csandi.near",
"gasBurnt":2428211671420,
"logs":[
],
"metadata":{
"gasProfile":null,
"version":1
},
"receiptIds":[
"GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc"
],
"status":{
"SuccessReceiptId":"GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc"
},
"tokensBurnt":"242821167142000000000"
},
"proof":[
{
"direction":"Left",
"hash":"BWhmGBmvzbX3WBP1RZQ59DB749sHSV2xS5pNyF6xAbbh"
},
{
"direction":"Right",
"hash":"H4YMDcd9Fh68KTwyPTwYuFb89KhfdGUoxRbBYzDcNAze"
},
{
"direction":"Right",
"hash":"9jv152euKvurdVkDYS5FKiiT4ej6xL1gRYTHoNbjwEZi"
},
{
"direction":"Right",
"hash":"BqQFHzSYzqDE8tMQkJT8PHFGxLmQrkFBcuTqFP4nTjx7"
}
]
},
"receipt":null
},
"transaction":{
"actions":[
{
"FunctionCall":{
"args":"eyJpbml0aWFsX3ByaWNlIjoxLjksInNwYWNpbmciOjIsImFscGhhX2lkIjoidXNuIiwiYmV0YV9pZCI6IndyYXAubmVhciIsInN3YXBfZmVlX3JhdGUiOjAuMDAzLCJwcm90b2NvbF90b2xsIjowLjAxfQ==",
"deposit":"0",
"gas":200000000000000,
"methodName":"create_new_pool"
}
}
],
"hash":"CkZYiXB3BEoXNuLDqcn5GjErkXghKGCB47yPyyze4kTf",
"nonce":75627675000007,
"publicKey":"ed25519:85yAx5mY8DinTWQfMn47cZTHMhZtLRAWZLpazYmetwno",
"receiverId":"dev-cliquidity-perk-jorge.near",
"signature":"ed25519:1CieS8AUSc7Y3S8By8adJaEXXydXcjvSA1uVXPgrdhkmGPpf5ykA7XWqJGZnDhMtymkp6eWDBEQzsBXkhybAbUV",
"signerId":"test1.csandi.near"
}
}
So I would like to know if there is anyway to get the failure message from the indexer?
Look in the next blocks for the corresponding receipt from the SuccessReceiptId (id GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc), and in its execution outcome you will find that status.
I cannot recommend more to watch or read the Data Flow in NEAR
FYI, just to follow up and clarify for anyone with this question, after following the above response by "Vlad Frolov", in order to get the Receipt Status, I had to check
shard.receiptExecutionOutcomes
which will provide the results of the receipts, so I started to track the receipts that I am interested in, in this case for
SuccessReceiptId (GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc)
"executionOutcome":{
"blockHash":"59F5pES9Myc2VT4JkppE95epCwtGAXYux9okbzpsh95K",
"id":"**GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc**",
"outcome":{
"executorId":"dev-cliquidity-perk-jorge.near",
"gasBurnt":2824274578054,
"logs":[
],
"metadata":{
"gasProfile":[
{
"cost":"BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"1323840555"
},
{
"cost":"CONTRACT_LOADING_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"35445963"
},
{
"cost":"CONTRACT_LOADING_BYTES",
"costCategory":"WASM_HOST_COST",
"gasUsed":"106584645000"
},
{
"cost":"READ_MEMORY_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"5219726400"
},
{
"cost":"READ_MEMORY_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"136847988"
},
{
"cost":"READ_REGISTER_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"2517165186"
},
{
"cost":"READ_REGISTER_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"11334630"
},
{
"cost":"STORAGE_READ_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"56356845750"
},
{
"cost":"STORAGE_READ_KEY_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"154762665"
},
{
"cost":"TOUCHING_TRIE_NODE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"193223471112"
},
{
"cost":"UTF8_DECODING_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"3111779061"
},
{
"cost":"UTF8_DECODING_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"9038994849"
},
{
"cost":"WASM_INSTRUCTION",
"costCategory":"WASM_HOST_COST",
"gasUsed":"11928316488"
},
{
"cost":"WRITE_MEMORY_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"2803794861"
},
{
"cost":"WRITE_MEMORY_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"313233780"
},
{
"cost":"WRITE_REGISTER_BASE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"2865522486"
},
{
"cost":"WRITE_REGISTER_BYTE",
"costCategory":"WASM_HOST_COST",
"gasUsed":"437179860"
}
],
"version":1
},
"receiptIds":[
"BPYU8T3o5mdsU4ewG3JdCLRe8ivpsGTehKxkifFAsboD"
],
**"status":{
"Failure":{
"ActionError":{
"index":0,
"kind":{
"FunctionCallError":{
"ExecutionError":"Smart contract panicked: The contract is not initialized"
}
}
}
}**
},
"tokensBurnt":"282427457805400000000"
},
"proof":[
{
"direction":"Left",
"hash":"5j1RhLnf5jGChUPxU9CPNbAGwSn6VnzBw7taJe5vSnYD"
},
{
"direction":"Right",
"hash":"AJ2kARUcYAkzsL3xmw4jAETZ61jtQuswf7RvhSxscKCR"
},
{
"direction":"Left",
"hash":"9vXQjFdTaQw5XjUKsRK6N3WFCg5zMVca5Ze2Qqznn3AM"
}
] }, "receipt":{
"predecessorId":"test1.csandi.near",
"receipt":{
"Action":{
"actions":[
{
"FunctionCall":{
"args":"eyJpbml0aWFsX3ByaWNlIjoxLjksInNwYWNpbmciOjIsImFscGhhX2lkIjoidXNuIiwiYmV0YV9pZCI6IndyYXAubmVhciIsInN3YXBfZmVlX3JhdGUiOjAuMDAzLCJwcm90b2NvbF90b2xsIjowLjAxfQ==",
"deposit":"0",
"gas":200000000000000,
"methodName":"create_new_pool"
}
}
],
"gasPrice":"346069590",
"inputDataIds":[
],
"outputDataReceivers":[
],
"signerId":"test1.csandi.near",
"signerPublicKey":"ed25519:85yAx5mY8DinTWQfMn47cZTHMhZtLRAWZLpazYmetwno"
}
},
"receiptId":"GrXdFKA9byvCmxGiQkGc9iaFn88FfePk4tfJhvcTGMwc",
"receiverId":"dev-cliquidity-perk-jorge.near" } }
And as you can see in the json response,the following status:
"status":{
"Failure":{
"ActionError":{
"index":0,
"kind":{
"FunctionCallError":{
"ExecutionError":"Smart contract panicked: The contract is not initialized"
}
}
}
}
Anyway to fully understand how transactions/receipts work this document helped a lot.

Amplify get Hosting URL in lambda as environment variable

I need the URL of Cloudfront distribution that I added with amplify cli as an environment variable.
Status:
I found how template variables are added in file "api-cloudformation-template.json" under my function config.
Desired Output variable from "hosting/S3AndCloudFront/template.json" is CloudFrontSecureURL.
So I added rows to lambda config file, like so:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Lambda resource stack creation using Amplify CLI",
"Parameters": {
...
"hostingS3AndCloudFrontHostingBucketName": { // working example
"Type": "String",
"Default": "hostingS3AndCloudFrontHostingBucketName"
},
"hostingS3AndCloudFrontCloudFrontSecureURL": { // my example
"Type": "String",
"Default": "hostingS3AndCloudFrontCloudFrontSecureURL"
},
},
"Resources": {
"LambdaFunction": {
"Type": "AWS::Lambda::Function",
"Metadata": {
"aws:asset:path": "./src",
"aws:asset:property": "Code"
},
"Properties": {
...
"Environment": {
"Variables": {
...
"HOSTING_S3ANDCLOUDFRONT_HOSTINGBUCKETNAME": {
"Ref": "hostingS3AndCloudFrontHostingBucketName"
},
"HOSTING_S3ANDCLOUDFRONT_CLOUDFRONTSECUREURL": {
"Ref": "hostingS3AndCloudFrontCloudFrontSecureURL"
}
}
},
}
}
....
},
....
}
I'm getting hostingS3AndCloudFrontCloudFrontSecureURL (default value) in process.env.HOSTING_S3ANDCLOUDFRONT_CLOUDFRONTSECUREURL after publishing function.
Try using the Outputs section of the template along with Fn::ImportValue function documentation HERE
CloudFront Stack:
{
...
"Outputs" : {
"CloudfrontDomainOutput" : {
"Description" : "The cloudfront domain",
"Value" : {
"Fn::GetAtt": [
"hostingS3AndCloudFrontCloudFrontSecureURL",
"DomainName"
]
},
"Export" : {
"Name" : {"Fn::Sub": "${AWS::StackName}-hostingS3AndCloudFrontCloudFrontSecureURL" }
}
}
}
Lambda Stack
{
...
"Environment": {
"Variables": {
"HOSTING_S3ANDCLOUDFRONT_HOSTINGBUCKETNAME": {
"Ref": "hostingS3AndCloudFrontHostingBucketName"
},
"HOSTING_S3ANDCLOUDFRONT_CLOUDFRONTSECUREURL": {
"Fn::ImportValue" : {"Fn::Sub" : "${CloudFront_Stack_Name}-hostingS3AndCloudFrontCloudFrontSecureURL"}
}
}
}
}

Swagger use a custom swagger.json file aspnet core

Pretty sure I am missing something clearly obvious but not seeing it.
How can I use my updated swagger.json file?
I took my boilerplate swagger/v1/swagger.json code and pasted it into the editor.swagger.io system. I then updated the descriptions etc, added examples to my models and then saved the contents as swagger.json.
Moved the file into the root of my api application, set the file to copy always.
public void ConfigureServices(IServiceCollection services)
{...
services.AddSwaggerGen(c => { c.SwaggerDoc("V1", new Info {Title = "Decrypto", Version = "0.0"}); });
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
...
app.UseSwagger();
//--the default works fine
// app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/V1/swagger.json", "Decrypto v1"); });
app.UseSwaggerUI(c => { c.SwaggerEndpoint("swagger.json", "Decrypto v1"); });
app.UseMvc();
}
I have tried a few different variation but none seem to be the trick. I don't really want to rewrite the work in SwaggerDoc as it seems dirty to me put documentation in the runtime.
the custom swagger.json file I want to use looks like this:
{
"swagger": "2.0",
"info": {
"version": "0.0",
"title": "My Title"
},
"paths": {
"/api/Decryption": {
"post": {
"tags": [
"API for taking encrypted values and getting the decrypted values back"
],
"summary": "",
"description": "",
"operationId": "Post",
"consumes": [
"application/json-patch+json",
"application/json",
"text/json",
"application/*+json"
],
"produces": [
"text/plain",
"application/json",
"text/json"
],
"parameters": [
{
"name": "units",
"in": "body",
"required": true,
"schema": {
"uniqueItems": false,
"type": "array",
"items": {
"$ref": "#/definitions/EncryptedUnit"
}
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"uniqueItems": false,
"type": "array",
"items": {
"$ref": "#/definitions/DecryptedUnit"
}
}
}
}
}
}
},
"definitions": {
"EncryptedUnit": {
"type": "object",
"properties": {
"value": {
"type": "string",
"example": "7OjLFw=="
},
"initializeVector": {
"type": "string",
"example": "5YVg="
},
"cipherText": {
"type": "string",
"example": "596F5AA48A882"
}
}
},
"DecryptedUnit": {
"type": "object",
"properties": {
"encrypted": {
"type": "string",
"example": "7OjLV="
},
"decrypted": {
"type": "string",
"example": "555-55-5555"
}
}
}
}
}
you need to configure PhysicalFileProvider and put your swagger.json into wwwroot or anywhere accessible by PhysicalFileProvider. After that you can access it using IFileProvider
Reference: https://www.c-sharpcorner.com/article/file-providers-in-asp-net-core/
Edit If you just add app.UseStaticFiles(); into your StartUp, you can access wwwroot without hastle.
Reference
Completely Different Approach
you may also consider to serve your file using Controller/Action
public IActionResult GetSwaggerDoc()
{
var file = Path.Combine(Directory.GetCurrentDirectory(),
"MyStaticFiles", "swagger.json");
return PhysicalFile(file, "application/json");
}
.NET Core 2.2 could server physical file to url resource like below.
But if you use custom swagger json, your api is fixed except you change it every time.
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
ILoggerFactory loggerFactory)
{
...
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(
Path.Combine(Directory.GetCurrentDirectory(),
"swagger/v1/swagger.json")),
RequestPath = "swagger/v1/swagger.json"
});
}

gmail is blocking my elastic search watcher email

I am using ES 5.2. I implemented a watcher.But each time watcher is getting triggered it generate email but google blocks that email due to security concern. So what can be solution for that?
My YML file is as below :
cluster.name: elasticsearch-logging
node.name: "elasticsearch-logging-0"
path.data: /var/lib/elasticsearch/data
xpack.notification.email.account:
gmail_account:
profile: gmail
smtp:
auth: true
starttls.enable: true
host: smtp.gmail.com
port: 587
user: ******.**#gmail.com
password: ******
While doing curl on watcher getting below response :
DOING CURL --
curl -XGET localhost:9200/_xpack/watcher/watch/last_watch
Getting below response:
{
"found": true,
"id": "lastwatch",
"status": {
"version": 5,
"state": {
"active": true,
"timestamp": "2017-06-16T00:39:16.654Z"
},
"lastchecked": "2017-06-16T00:43:00.229Z",
"last_met_condition": "2017-06-16T00:43:00.229Z",
"actions": {
"email_admin": {
"ack": {
"timestamp": "2017-06-16T00:39:16.654Z",
"state": "awaits_successful_execution"
},
"last_execution": {
"timestamp": "2017-06-16T00:43:00.229Z",
"successful": false,
"reason": "MessagingException[failed to send email with subject [404 recently encountered] via account [gmail_account]]; nested: AuthenticationFailedException[534-5.7.14 https://accounts.google.com/signin/continue?sarp=1&scc=1&pltn534-5.7.14 q0WEdpll7GFx7wL5ZoIKlaHy0JIWKkJEAaiNf5hWY11ZPPsJb6u7h9z0Xe\n534-5.7.14 kWiT264a1EJgbKW5ESeccxI0uUZ_3X4klQS4jBjB7dDw6pRU490p-yKtXkL2-Ik\n534-5.7.14 vMoQFBgYsmH2WbbGFC3Z63GBpWVH0O9LmpVsB89ZsSreIXN_bb0AX3UWwoX4dTb4UiXtmi\nQI Please log in via your web browser and\n534-5.7.14 then try again.\n534-5.7.14 Learn more at\n534 5.7.14 https://support.google.com/mail/answer/78754 a22sm752699pfc.115 - gsmtp\n]; "
}
}
}
},
"watch": {
"trigger": {
"schedule": {
"cron": "0 0/1 * * * ?"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"logstash*"
],
"types": [],
"body": {
"query": {
"bool": {
"must": {
"match": {
"methodName": "getSSLConnectionSocketFactory"
}
}
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"gt": 0
}
}
},
"actions": {
"email_admin": {
"email": {
"profile": "standard",
"to": [
"****.*****#gmail.com"
],
"subject": "404 recently encountered"
}
}
}
}
}
Looks like a javax.mail issue and you need to turn on less secure apps.

Resources