Projects STRLCPY gophish Commits 26d99b5a
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    config/config.go
    skipped 31 lines
    32 32   PhishConf PhishServer `json:"phish_server"`
    33 33   DBName string `json:"db_name"`
    34 34   DBPath string `json:"db_path"`
     35 + DBSSLCaPath string `json:"db_sslca_path"`
    35 36   MigrationsPath string `json:"migrations_prefix"`
    36 37   TestFlag bool `json:"test_flag"`
    37 38   ContactAddress string `json:"contact_address"`
    skipped 28 lines
  • ■ ■ ■ ■ ■ ■
    models/models.go
    skipped 4 lines
    5 5   "fmt"
    6 6   "io"
    7 7   "time"
     8 + "crypto/tls"
     9 + "crypto/x509"
     10 + "io/ioutil"
    8 11   
    9 12   "bitbucket.org/liamstask/goose/lib/goose"
    10 13   
    11  - _ "github.com/go-sql-driver/mysql" // Blank import needed to import mysql
     14 + mysql "github.com/go-sql-driver/mysql"
    12 15   "github.com/gophish/gophish/config"
    13 16   log "github.com/gophish/gophish/logger"
    14 17   "github.com/jinzhu/gorm"
    skipped 81 lines
    96 99   log.Error(err)
    97 100   return err
    98 101   }
     102 + 
     103 + // Register certificates for tls encrypted db connections
     104 + if conf.DBSSLCaPath != "" {
     105 + switch conf.DBName {
     106 + case "mysql":
     107 + rootCertPool := x509.NewCertPool()
     108 + pem, err := ioutil.ReadFile(conf.DBSSLCaPath)
     109 + if err != nil {
     110 + log.Error(err)
     111 + return err
     112 + }
     113 + if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
     114 + log.Error("Failed to append PEM.")
     115 + return err
     116 + }
     117 + mysql.RegisterTLSConfig("ssl_ca", &tls.Config{
     118 + RootCAs: rootCertPool,
     119 + })
     120 + // Default database is sqlite3, which supports no tls, as connection
     121 + // is file based
     122 + default:
     123 + }
     124 + }
     125 + 
    99 126   // Open our database connection
    100 127   i := 0
    101 128   for {
    skipped 50 lines
Please wait...
Page is in error, reload to recover