summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-02-08 07:34:39 -0500
committerChristopher Speller <crspeller@gmail.com>2016-02-08 07:34:39 -0500
commitbe70bbc2f027bcc32d54e03c6b66f7e3aadec425 (patch)
tree02cbf3694b44045422b46fdb90a4b272c1fad976 /api
parent9b35fb5fa59099fe644a1b1ef3734b09b50f98bf (diff)
parent9f5f18a93a6db2b9c1089862fb68c2ee33e634ca (diff)
downloadchat-be70bbc2f027bcc32d54e03c6b66f7e3aadec425.tar.gz
chat-be70bbc2f027bcc32d54e03c6b66f7e3aadec425.tar.bz2
chat-be70bbc2f027bcc32d54e03c6b66f7e3aadec425.zip
Merge pull request #2083 from mattermost/plt-1879
PLT-1879 Add config setting to accept unsigned TLS certs for SSO and outgoing hooks, also fix deleteā€¦
Diffstat (limited to 'api')
-rw-r--r--api/command.go7
-rw-r--r--api/post.go11
-rw-r--r--api/user.go6
-rw-r--r--api/webhook.go2
4 files changed, 21 insertions, 5 deletions
diff --git a/api/command.go b/api/command.go
index 49d9e84f1..bebe6629c 100644
--- a/api/command.go
+++ b/api/command.go
@@ -4,6 +4,7 @@
package api
import (
+ "crypto/tls"
"fmt"
"io/ioutil"
"net/http"
@@ -173,7 +174,11 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) {
method = "GET"
}
- client := &http.Client{}
+ tr := &http.Transport{
+ TLSClientConfig: &tls.Config{InsecureSkipVerify: *utils.Cfg.ServiceSettings.EnableInsecureOutgoingConnections},
+ }
+ client := &http.Client{Transport: tr}
+
req, _ := http.NewRequest(method, cmd.URL, strings.NewReader(p.Encode()))
req.Header.Set("Accept", "application/json")
if cmd.Method == model.COMMAND_METHOD_POST {
diff --git a/api/post.go b/api/post.go
index c17da262f..fadabd66e 100644
--- a/api/post.go
+++ b/api/post.go
@@ -4,6 +4,7 @@
package api
import (
+ "crypto/tls"
"fmt"
l4g "github.com/alecthomas/log4go"
"github.com/gorilla/mux"
@@ -401,7 +402,10 @@ func handleWebhookEventsAndForget(c *Context, post *model.Post, team *model.Team
p.Set("text", post.Message)
p.Set("trigger_word", firstWord)
- client := &http.Client{}
+ tr := &http.Transport{
+ TLSClientConfig: &tls.Config{InsecureSkipVerify: *utils.Cfg.ServiceSettings.EnableInsecureOutgoingConnections},
+ }
+ client := &http.Client{Transport: tr}
for _, url := range hook.CallbackURLs {
go func(url string) {
@@ -682,7 +686,10 @@ func sendNotifications(c *Context, post *model.Post, team *model.Team, channel *
msg.Message = senderName + userLocale("api.post.send_notifications_and_forget.push_mention") + channelName
}
- httpClient := http.Client{}
+ tr := &http.Transport{
+ TLSClientConfig: &tls.Config{InsecureSkipVerify: *utils.Cfg.ServiceSettings.EnableInsecureOutgoingConnections},
+ }
+ httpClient := &http.Client{Transport: tr}
request, _ := http.NewRequest("POST", *utils.Cfg.EmailSettings.PushNotificationServer+"/api/v1/send_push", strings.NewReader(msg.ToJson()))
l4g.Debug(utils.T("api.post.send_notifications_and_forget.push_notification.debug"), msg.DeviceId, msg.Message)
diff --git a/api/user.go b/api/user.go
index 9926f3ff3..507c83d28 100644
--- a/api/user.go
+++ b/api/user.go
@@ -5,6 +5,7 @@ package api
import (
"bytes"
+ "crypto/tls"
b64 "encoding/base64"
"fmt"
l4g "github.com/alecthomas/log4go"
@@ -1960,7 +1961,10 @@ func AuthorizeOAuthUser(service, code, state, redirectUri string) (io.ReadCloser
p.Set("grant_type", model.ACCESS_TOKEN_GRANT_TYPE)
p.Set("redirect_uri", redirectUri)
- client := &http.Client{}
+ tr := &http.Transport{
+ TLSClientConfig: &tls.Config{InsecureSkipVerify: *utils.Cfg.ServiceSettings.EnableInsecureOutgoingConnections},
+ }
+ client := &http.Client{Transport: tr}
req, _ := http.NewRequest("POST", sso.TokenEndpoint, strings.NewReader(p.Encode()))
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
diff --git a/api/webhook.go b/api/webhook.go
index 3906d09be..c0f8ea506 100644
--- a/api/webhook.go
+++ b/api/webhook.go
@@ -238,7 +238,7 @@ func getOutgoingHooks(c *Context, w http.ResponseWriter, r *http.Request) {
}
func deleteOutgoingHook(c *Context, w http.ResponseWriter, r *http.Request) {
- if !utils.Cfg.ServiceSettings.EnableIncomingWebhooks {
+ if !utils.Cfg.ServiceSettings.EnableOutgoingWebhooks {
c.Err = model.NewLocAppError("deleteOutgoingHook", "api.webhook.delete_outgoing.disabled.app_error", nil, "")
c.Err.StatusCode = http.StatusNotImplemented
return