Skip to content

Commit 0fd45a8

Browse files
author
Frank Martinez
committed
update rest activity defaults
1 parent cf6cec4 commit 0fd45a8

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

activity/rest/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ flogo install github.com/project-flogo/contrib/activity/rest
2626
| sslConfig | object | SSL configuration
2727

2828

29-
#### *sslConfig* Object:
29+
#### *sslConfig* Object:
3030
| Property | Type | Description
3131
|:--- | :--- | :---
32-
| skipVerify | bool | Skip SSL validation, defaults to false
33-
| useSystemCert | bool | Use the systems root certificate file, defaults to false
32+
| skipVerify | bool | Skip SSL validation, defaults to true
33+
| useSystemCert | bool | Use the systems root certificate file, defaults to true
3434
| caFile | string | The path to PEM encoded root certificates file
3535
| certFile | string | The path to PEM encoded client certificate
3636
| keyFile | string | The path to PEM encoded client key
3737

38+
*Note: used if URI is https*
3839
### Input:
3940
| Name | Type | Description
4041
|:--- | :--- | :---

activity/rest/activity.go

+18-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package rest
33
import (
44
"bytes"
55
"encoding/json"
6+
"github.com/DataDog/zstd"
67
"io"
78
"io/ioutil"
89
"net/http"
@@ -62,9 +63,23 @@ func New(ctx activity.InitContext) (activity.Activity, error) {
6263
if strings.HasPrefix(s.Uri, "https") {
6364

6465
cfg := &ssl.Config{}
65-
err := cfg.FromMap(s.SSLConfig)
66-
if err != nil {
67-
return nil, err
66+
67+
if len(s.SSLConfig) != 0 {
68+
err := cfg.FromMap(s.SSLConfig)
69+
if err != nil {
70+
return nil, err
71+
}
72+
73+
if _, set := s.SSLConfig["skipVerify"]; !set {
74+
cfg.SkipVerify = true
75+
}
76+
if _, set := s.SSLConfig["useSystemCert"]; !set {
77+
cfg.UseSystemCert = true
78+
}
79+
} else {
80+
//using ssl but not configured, use defaults
81+
cfg.SkipVerify = true
82+
cfg.UseSystemCert = true
6883
}
6984

7085
tlsConfig, err := ssl.NewClientTLSConfig(cfg)

activity/rest/descriptor.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
{
4343
"name": "skipVerify",
4444
"type": "boolean",
45-
"value": "false",
45+
"value": "true",
4646
"description" : "Skip SSL validation"
4747
},
4848
{
4949
"name": "useSystemCert",
5050
"type": "boolean",
51-
"value": "false",
51+
"value": "true",
5252
"description" : "Use the systems root certificate file"
5353
},
5454
{

activity/rest/go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module github.com/project-flogo/contrib/activity/rest
22

33
require (
4+
github.com/DataDog/zstd v1.4.0 // indirect
45
github.com/pkg/errors v0.8.1 // indirect
56
github.com/project-flogo/core v0.9.0
67
github.com/stretchr/testify v1.3.0

activity/rest/go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/DataDog/zstd v1.4.0 h1:vhoV+DUHnRZdKW1i5UMjAk2G4JY8wN4ayRfYDNdEhwo=
2+
github.com/DataDog/zstd v1.4.0/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
13
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
24
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
35
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=

0 commit comments

Comments
 (0)