Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
bootstrap: Merge pull request #4 from flynn/custom-controller-cert-name
Browse files Browse the repository at this point in the history
Support setting the controller-cert dns name
  • Loading branch information
titanous committed Jun 22, 2014
2 parents 75d9286 + 404741f commit 9a52140
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions add_route_action.go
Expand Up @@ -42,6 +42,7 @@ func (a *AddRouteAction) Run(s *State) error {
return err
}
route := a.Route.HTTPRoute()
route.Domain = interpolate(s, route.Domain)
route.TLSCert = cert.Cert
route.TLSKey = cert.PrivateKey
a.Route = route.ToRoute()
Expand Down
6 changes: 3 additions & 3 deletions bootstrapper/manifest.json
Expand Up @@ -180,7 +180,7 @@
{
"id": "controller-cert",
"action": "gen-tls-cert",
"hosts": ["localhost", "127.0.0.1"]
"hosts": ["{{ or (getenv `CONTROLLER_DOMAIN`) `localhost` }}", "127.0.0.1"]
},
{
"id": "strowger-wait",
Expand All @@ -206,12 +206,12 @@
"type": "http",
"config": {
"service": "flynn-controller",
"domain": "localhost"
"domain": "{{ or (getenv `CONTROLLER_DOMAIN`) `localhost` }}"
}
},
{
"id": "log-complete",
"action": "log",
"output": "Flynn bootstrapping complete. Install flynn-cli and paste the line below into a new terminal window:\n\nflynn server-add -g localhost:2201 -p {{ (index .StepData `controller-cert`).Pin }} default https://localhost:8081 {{ (index .StepData `controller-key`).Data }}"
"output": "Flynn bootstrapping complete. Install flynn-cli and paste the line below into a new terminal window:\n\nflynn server-add -g localhost:2201 -p {{ (index .StepData `controller-cert`).Pin }} default https://{{ or (getenv `CONTROLLER_DOMAIN`) `localhost` }}:8081 {{ (index .StepData `controller-key`).Data }}"
}
]
9 changes: 5 additions & 4 deletions gen_tls_cert_action.go
Expand Up @@ -42,11 +42,11 @@ func (c *TLSCert) String() string {
func (a *GenTLSCertAction) Run(s *State) (err error) {
data := &TLSCert{}
s.StepData[a.ID] = data
data.Cert, data.PrivateKey, data.Pin, err = a.generateCert()
data.Cert, data.PrivateKey, data.Pin, err = a.generateCert(s)
return
}

func (a *GenTLSCertAction) generateCert() (cert, privKey, pin string, err error) {
func (a *GenTLSCertAction) generateCert(s *State) (cert, privKey, pin string, err error) {
priv, err := rsa.GenerateKey(rand.Reader, 2048)
if err != nil {
return
Expand All @@ -66,10 +66,11 @@ func (a *GenTLSCertAction) generateCert() (cert, privKey, pin string, err error)
}

for _, h := range a.Hosts {
if ip := net.ParseIP(h); ip != nil {
host := interpolate(s, h)
if ip := net.ParseIP(host); ip != nil {
template.IPAddresses = append(template.IPAddresses, ip)
} else {
template.DNSNames = append(template.DNSNames, h)
template.DNSNames = append(template.DNSNames, host)
}
}

Expand Down

0 comments on commit 9a52140

Please sign in to comment.