/
tls.go
37 lines (31 loc) · 971 Bytes
/
tls.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package tls
import (
"fmt"
"os"
"path"
)
const (
// VolumePath is the path at which the tls cert and private key (if any)
// will be mounted in the pachd pod
VolumePath = "/pachd-tls-cert"
// CertFile is the name of the mounted file containing a TLS certificate
// that identifies pachd
CertFile = "tls.crt"
// KeyFile is the name of the mounted file containing a private key
// corresponding to the public certificate in TLSCertFile
KeyFile = "tls.key"
)
// GetCertPaths gets the paths to the cert and key files within a cluster
func GetCertPaths() (certPath string, keyPath string, err error) {
certPath = path.Join(VolumePath, CertFile)
if _, err = os.Stat(certPath); err != nil {
err = fmt.Errorf("could not stat public cert at %s: %v", certPath, err)
return
}
keyPath = path.Join(VolumePath, KeyFile)
if _, err = os.Stat(keyPath); err != nil {
err = fmt.Errorf("could not stat private key at %s: %v", keyPath, err)
return
}
return
}