summaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-01-19 19:07:44 +0000
committerGitHub <noreply@github.com>2020-01-19 19:07:44 +0000
commit1d7b7504d07e6d58dd7c4a37055a2d754374dee2 (patch)
tree8776a6daeb0c6eb5baf78258258ee26d6176a3e8 /modules/setting
parent1803b38efcb919e43ab519e0f0e132d461149c39 (diff)
downloadgitea-1d7b7504d07e6d58dd7c4a37055a2d754374dee2.tar.gz
gitea-1d7b7504d07e6d58dd7c4a37055a2d754374dee2.zip
Make CertFile and KeyFile relative to CustomPath (#9868)
* Make CertFile and KeyFile relative to CustomPath The current code will absolute CertFile and KeyFile against the current working directory. This is quite unexpected for users. This code makes relative paths absolute against the CustomPath. Fix #4196 * Improve error reporting when reading certificates * Apply suggestions from code review Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/setting.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 17c84d3d31..4183c203ed 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -554,6 +554,12 @@ func NewContext() {
Protocol = HTTPS
CertFile = sec.Key("CERT_FILE").String()
KeyFile = sec.Key("KEY_FILE").String()
+ if !filepath.IsAbs(CertFile) && len(CertFile) > 0 {
+ CertFile = filepath.Join(CustomPath, CertFile)
+ }
+ if !filepath.IsAbs(KeyFile) && len(KeyFile) > 0 {
+ KeyFile = filepath.Join(CustomPath, KeyFile)
+ }
case "fcgi":
Protocol = FCGI
case "fcgi+unix":