mirror of https://github.com/perkeep/perkeep.git
Merge "camlistored: use osutil for default TLS cert/key"
This commit is contained in:
commit
d0e36512f7
|
@ -134,6 +134,20 @@ func KeyBlobsDir() string {
|
|||
return filepath.Join(CamliConfigDir(), "keyblobs")
|
||||
}
|
||||
|
||||
// DefaultTLSCert returns the path to the default TLS certificate
|
||||
// file that is used (creating if necessary) when TLS is specified
|
||||
// without the cert file.
|
||||
func DefaultTLSCert() string {
|
||||
return filepath.Join(CamliConfigDir(), "selfgen_pem.crt")
|
||||
}
|
||||
|
||||
// DefaultTLSKey returns the path to the default TLS key
|
||||
// file that is used (creating if necessary) when TLS is specified
|
||||
// without the key file.
|
||||
func DefaultTLSKey() string {
|
||||
return filepath.Join(CamliConfigDir(), "selfgen_pem.key")
|
||||
}
|
||||
|
||||
// Find the correct absolute path corresponding to a relative path,
|
||||
// searching the following sequence of directories:
|
||||
// 1. Working Directory
|
||||
|
|
|
@ -30,11 +30,6 @@ import (
|
|||
"camlistore.org/pkg/osutil"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultTLSCert = "config/selfgen_pem.crt"
|
||||
DefaultTLSKey = "config/selfgen_pem.key"
|
||||
)
|
||||
|
||||
// various parameters derived from the high-level user config
|
||||
// and needed to set up the low-level config.
|
||||
type configPrefixesParams struct {
|
||||
|
@ -508,14 +503,14 @@ func genLowLevelPrefixes(params *configPrefixesParams, ownerName string) (m json
|
|||
}
|
||||
|
||||
searchArgs := map[string]interface{}{
|
||||
"index": params.indexerPath,
|
||||
"owner": params.searchOwner.String(),
|
||||
"index": params.indexerPath,
|
||||
"owner": params.searchOwner.String(),
|
||||
}
|
||||
if params.memoryIndex {
|
||||
searchArgs["slurpToMemory"] = true
|
||||
}
|
||||
m["/my-search/"] = map[string]interface{}{
|
||||
"handler": "search",
|
||||
"handler": "search",
|
||||
"handlerArgs": searchArgs,
|
||||
}
|
||||
}
|
||||
|
@ -585,8 +580,8 @@ func genLowLevelConfig(conf *Config) (lowLevelConf *Config, err error) {
|
|||
obj["TLSCertFile"] = tlsCert
|
||||
obj["TLSKeyFile"] = tlsKey
|
||||
} else {
|
||||
obj["TLSCertFile"] = DefaultTLSCert
|
||||
obj["TLSKeyFile"] = DefaultTLSKey
|
||||
obj["TLSCertFile"] = osutil.DefaultTLSCert()
|
||||
obj["TLSKeyFile"] = osutil.DefaultTLSKey()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,11 +76,6 @@ import (
|
|||
_ "camlistore.org/pkg/importer/flickr"
|
||||
)
|
||||
|
||||
const (
|
||||
defCert = serverconfig.DefaultTLSCert
|
||||
defKey = serverconfig.DefaultTLSKey
|
||||
)
|
||||
|
||||
var (
|
||||
flagVersion = flag.Bool("version", false, "show version")
|
||||
flagConfigFile = flag.String("configfile", "",
|
||||
|
@ -160,6 +155,8 @@ func genSelfTLS(listen string) error {
|
|||
return fmt.Errorf("Failed to create certificate: %s", err)
|
||||
}
|
||||
|
||||
defCert := osutil.DefaultTLSCert()
|
||||
defKey := osutil.DefaultTLSKey()
|
||||
certOut, err := os.Create(defCert)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open %s for writing: %s", defCert, err)
|
||||
|
@ -319,6 +316,8 @@ func setupTLS(ws *webserver.Server, config *serverconfig.Config, listen string)
|
|||
exitf("TLSCertFile and TLSKeyFile must both be either present or absent")
|
||||
}
|
||||
|
||||
defCert := osutil.DefaultTLSCert()
|
||||
defKey := osutil.DefaultTLSKey()
|
||||
if cert == defCert && key == defKey {
|
||||
_, err1 := os.Stat(cert)
|
||||
_, err2 := os.Stat(key)
|
||||
|
|
Loading…
Reference in New Issue