Commit fa661338 authored by njapke's avatar njapke
Browse files

Fix hardcoded filename in alexandra.

parent c378db55
Pipeline #164484 passed with stages
in 16 minutes and 31 seconds
......@@ -87,9 +87,6 @@ func main() {
log.Info().Msg("No Loglevel specified, using 'debug'")
}
// Setup alexandra
m := alexandra.NewMiddleware(c.nodesCert, c.nodesKey, c.lightHouse, c.isProxied, c.proxyHost, c.experimental)
if c.alexandraCert == "" {
log.Fatal().Msg("alexandra server: no certificate file given")
}
......@@ -102,6 +99,9 @@ func main() {
log.Fatal().Msg("alexandra server: no root certificate file given")
}
// Setup alexandra
m := alexandra.NewMiddleware(c.nodesCert, c.nodesKey, c.caCert, c.lightHouse, c.isProxied, c.proxyHost, c.experimental)
// Load server's certificate and private key
loadedServerCert, err := tls.LoadX509KeyPair(c.alexandraCert, c.alexandraKey)
......
......@@ -42,17 +42,18 @@ type keygroupSet struct {
type ClientsMgr struct {
// Mutex for the keygroups map, because it might be changed while iterated over
sync.Mutex
clients map[string]*Client
clientsCert, clientsKey, lighthouse string
keygroups map[string]*keygroupSet
experimental bool
clients map[string]*Client
clientsCert, clientsKey, caCert, lighthouse string
keygroups map[string]*keygroupSet
experimental bool
}
func newClientsManager(clientsCert string, clientsKey string, lighthouse string, experimental bool) *ClientsMgr {
func newClientsManager(clientsCert string, clientsKey string, caCert string, lighthouse string, experimental bool) *ClientsMgr {
mgr := &ClientsMgr{
clients: make(map[string]*Client),
clientsCert: clientsCert,
clientsKey: clientsKey,
caCert: caCert,
lighthouse: lighthouse,
keygroups: make(map[string]*keygroupSet),
experimental: experimental,
......@@ -209,7 +210,7 @@ func (m *ClientsMgr) getClientTo(host string, nodeID string) (client *Client) {
return
}
client = newClient(nodeID, host, m.clientsCert, m.clientsKey)
client = newClient(nodeID, host, m.clientsCert, m.clientsKey, m.caCert)
m.clients[nodeID] = client
return
}
......
......@@ -25,7 +25,7 @@ type Client struct {
ReadSpeed float32
}
func newClient(nodeID string, host string, certFile string, keyFile string) *Client {
func newClient(nodeID string, host string, certFile string, keyFile string, caCert string) *Client {
if certFile == "" {
log.Fatal().Msg("fredclient: no certificate file given")
......@@ -45,7 +45,7 @@ func newClient(nodeID string, host string, certFile string, keyFile string) *Cli
// Create a new cert pool and add our own CA certificate
rootCAs := x509.NewCertPool()
loaded, err := ioutil.ReadFile("/cert/ca.crt")
loaded, err := ioutil.ReadFile(caCert)
if err != nil {
log.Fatal().Msgf("unexpected missing certfile: %v", err)
......
......@@ -12,12 +12,12 @@ type Middleware struct {
}
// NewMiddleware creates a new Middleware for requests from Alexandra Clients
func NewMiddleware(nodesCert string, nodesKey string, lighthouse string, isProxied bool, proxyHost string, experimental bool) *Middleware {
func NewMiddleware(nodesCert string, nodesKey string, caCert string, lighthouse string, isProxied bool, proxyHost string, experimental bool) *Middleware {
return &Middleware{
isProxied: isProxied,
proxyHost: proxyHost,
clientsMgr: newClientsManager(nodesCert, nodesKey, lighthouse, experimental),
clientsMgr: newClientsManager(nodesCert, nodesKey, caCert, lighthouse, experimental),
lighthouse: lighthouse,
cache: newCache(),
experimental: experimental,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment