52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
// Copyright 2014 ISRG. All rights reserved
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/cactus/go-statsd-client/statsd"
|
|
"github.com/letsencrypt/boulder/Godeps/_workspace/src/github.com/streadway/amqp"
|
|
|
|
"github.com/letsencrypt/boulder/ca"
|
|
"github.com/letsencrypt/boulder/cmd"
|
|
blog "github.com/letsencrypt/boulder/log"
|
|
"github.com/letsencrypt/boulder/rpc"
|
|
)
|
|
|
|
func main() {
|
|
app := cmd.NewAppShell("boulder-ca")
|
|
app.Action = func(c cmd.Config) {
|
|
stats, err := statsd.NewClient(c.Statsd.Server, c.Statsd.Prefix)
|
|
cmd.FailOnError(err, "Couldn't connect to statsd")
|
|
|
|
// Set up logging
|
|
auditlogger, err := blog.Dial(c.Syslog.Network, c.Syslog.Server, c.Syslog.Tag, stats)
|
|
cmd.FailOnError(err, "Could not connect to Syslog")
|
|
|
|
cai, err := ca.NewCertificateAuthorityImpl(auditlogger, c.CA.Server, c.CA.AuthKey, c.CA.Profile)
|
|
cmd.FailOnError(err, "Failed to create CA impl")
|
|
|
|
go cmd.ProfileCmd("CA", stats, auditlogger)
|
|
|
|
|
|
for {
|
|
ch := cmd.AmqpChannel(c.AMQP.Server)
|
|
closeChan := ch.NotifyClose(make(chan *amqp.Error, 1))
|
|
|
|
sac, err := rpc.NewStorageAuthorityClient(c.AMQP.SA.Client, c.AMQP.SA.Client, ch)
|
|
cmd.FailOnError(err, "Failed to create SA client")
|
|
|
|
cai.SA = &sac
|
|
|
|
cas, err := rpc.NewCertificateAuthorityServer(c.AMQP.CA.Server, ch, cai)
|
|
cmd.FailOnError(err, "Unable to create CA server")
|
|
|
|
cmd.RunUntilSignaled(auditlogger, cas, closeChan)
|
|
}
|
|
}
|
|
|
|
app.Run()
|
|
}
|