Open isidhux opened 2 months ago
I am integrating slack with an application. while running code with 'go test', everything is working fine, but once i deploy the app in docker container after generating a build, it is throwing the following error:
"Post \"https://slack.com/api/chat.postMessage\": tls: failed to verify certificate: x509: certificate signed by unknown authority"
It should send the messages
generate a build and run the binary in ubuntu:latest docker container i am using docker compose to run the app and redis container use the code from slack-go tutorial https://medium.com/@wambuirebeka/how-to-integrate-slack-notifications-using-golang-84451aca27e3#:~:text=New()%20New%20builds%20a,the%20provided%20token%20and%20options.&text=Our%20func%20sendSlackMessage%20takes%20in,a%20message%20to%20a%20channel.
type Slack struct { SlackClient *slack.Client ChannelID string }
func (s *Slack) SendSlackMessage(message string) error { ChannelID, timestamp, err := s.SlackClient.PostMessage(s.ChannelID, slack.MsgOptionText(message, false)) if err != nil { return err } fmt.Printf("Message sent successfully to %s channel at %s\n", ChannelID, timestamp) return nil }
slackObj := &Slack{ SlackClient: slack.New("token-string"), ChannelID: "channel-id", } if err := slackObj.SendSlackMessage("Vcenter Sync Failed"); err != nil { t.Fatalf("Error occured while sending slack msg: %v \n", err) }
executes without problem in host machine, but gives problem when deployed to container
What happened
I am integrating slack with an application. while running code with 'go test', everything is working fine, but once i deploy the app in docker container after generating a build, it is throwing the following error:
"Post \"https://slack.com/api/chat.postMessage\": tls: failed to verify certificate: x509: certificate signed by unknown authority"
Expected behavior
It should send the messages
Steps to reproduce
generate a build and run the binary in ubuntu:latest docker container i am using docker compose to run the app and redis container use the code from slack-go tutorial https://medium.com/@wambuirebeka/how-to-integrate-slack-notifications-using-golang-84451aca27e3#:~:text=New()%20New%20builds%20a,the%20provided%20token%20and%20options.&text=Our%20func%20sendSlackMessage%20takes%20in,a%20message%20to%20a%20channel.
reproducible code
type Slack struct { SlackClient *slack.Client ChannelID string }
func (s *Slack) SendSlackMessage(message string) error { ChannelID, timestamp, err := s.SlackClient.PostMessage(s.ChannelID, slack.MsgOptionText(message, false)) if err != nil { return err } fmt.Printf("Message sent successfully to %s channel at %s\n", ChannelID, timestamp) return nil }
slackObj := &Slack{ SlackClient: slack.New("token-string"), ChannelID: "channel-id", } if err := slackObj.SendSlackMessage("Vcenter Sync Failed"); err != nil { t.Fatalf("Error occured while sending slack msg: %v \n", err) }
Versions