Skip to content

Commit

Permalink
Added -i parameter to allow for insecure skipping of tls-verification
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Falk authored and justmiles committed Nov 18, 2022
1 parent 2202cd3 commit 69cb976
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Flags:
-x, --exclude strings list of exclude file patterns (regex) for that will be applied on markdown file paths
-w, --hardwraps Render newlines as <br />
-h, --help help for markdown2confluence
-i, --insecuretls Skip certificate validation. (e.g. for self-signed certificates)
-m, --modified-since int Only upload files that have modifed in the past n minutes
--parent string Optional parent page to next content under
-p, --password string Confluence password. (Alternatively set CONFLUENCE_PASSWORD environment variable)
Expand Down
7 changes: 7 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package cmd

import (
"crypto/tls"
"fmt"
"log"
"net/http"
"os"

lib "github.com/justmiles/go-markdown2confluence/lib"
Expand All @@ -22,6 +24,7 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&m.Password, "password", "p", "", "Confluence password. (Alternatively set CONFLUENCE_PASSWORD environment variable)")
rootCmd.PersistentFlags().StringVarP(&m.AccessToken, "access-token", "a", "", "Confluence access-token. (Alternatively set CONFLUENCE_ACCESS_TOKEN environment variable)")
rootCmd.PersistentFlags().StringVarP(&m.Endpoint, "endpoint", "e", lib.DefaultEndpoint, "Confluence endpoint. (Alternatively set CONFLUENCE_ENDPOINT environment variable)")
rootCmd.PersistentFlags().BoolVarP(&m.InsecureTLS, "insecuretls", "i", false, "Skip certificate validation. (e.g. for self-signed certificates)")
rootCmd.PersistentFlags().StringVar(&m.Parent, "parent", "", "Optional parent page to next content under")
rootCmd.PersistentFlags().BoolVarP(&m.Debug, "debug", "d", false, "Enable debug logging")
rootCmd.PersistentFlags().BoolVarP(&m.UseDocumentTitle, "use-document-title", "", false, "Will use the Markdown document title (# Title) if available")
Expand All @@ -44,6 +47,10 @@ var rootCmd = &cobra.Command{
if err != nil {
log.Fatal(err)
}
if m.InsecureTLS {
fmt.Println("Warning: TLS verification is disabled. This allows for man-in-the-middle-attacks.")
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
}

errors := m.Run()
for _, err := range errors {
Expand Down
3 changes: 2 additions & 1 deletion lib/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ type Markdown2Confluence struct {
Username string
Password string
AccessToken string
InsecureTLS bool
Endpoint string
Parent string
SourceMarkdown []string
ExcludeFilePatterns []string
client *confluence.Client
}

// CreateClient returns a new markdown clietn
// CreateClient returns a new markdown client
func (m *Markdown2Confluence) CreateClient() {
m.client = new(confluence.Client)
m.client.Username = m.Username
Expand Down

0 comments on commit 69cb976

Please sign in to comment.