Quellcode durchsuchen

More info on startup

Carl Tashian vor 4 Jahren
Ursprung
Commit
43f2c655b9
2 geänderte Dateien mit 13 neuen und 4 gelöschten Zeilen
  1. 2 0
      authority/authority.go
  2. 11 4
      ca/ca.go

+ 2 - 0
authority/authority.go

@@ -85,6 +85,7 @@ type AuthorityInfo struct {
 	RootX509Certs      []*x509.Certificate
 	SSHCAUserPublicKey []byte
 	SSHCAHostPublicKey []byte
+	DNSNames           []string
 }
 
 // New creates and initiates a new Authority type.
@@ -570,6 +571,7 @@ func (a *Authority) GetInfo() AuthorityInfo {
 	ai := AuthorityInfo{
 		StartTime:     a.startTime,
 		RootX509Certs: a.rootX509Certs,
+		DNSNames:      a.config.DNSNames,
 	}
 	if a.sshCAUserCertSignKey != nil {
 		ai.SSHCAUserPublicKey = ssh.MarshalAuthorizedKey(a.sshCAUserCertSignKey.PublicKey())

+ 11 - 4
ca/ca.go

@@ -1,15 +1,14 @@
 package ca
 
 import (
-	"crypto/sha256"
 	"crypto/tls"
 	"crypto/x509"
-	"encoding/hex"
 	"fmt"
 	"log"
 	"net/http"
 	"net/url"
 	"reflect"
+	"strings"
 	"sync"
 
 	"github.com/go-chi/chi"
@@ -28,6 +27,7 @@ import (
 	scepAPI "github.com/smallstep/certificates/scep/api"
 	"github.com/smallstep/certificates/server"
 	"github.com/smallstep/nosql"
+	"go.step.sm/crypto/x509util"
 )
 
 type options struct {
@@ -300,12 +300,19 @@ func (ca *CA) Run() error {
 
 	if !ca.opts.quiet {
 		authorityInfo := ca.auth.GetInfo()
-		log.Printf("Address: %s", ca.config.Address)
+		log.Printf("Welcome to step-ca.")
+		log.Printf("The primary server URL is https://%s%s",
+			authorityInfo.DNSNames[0],
+			ca.config.Address[strings.LastIndex(ca.config.Address, ":"):])
+		if len(authorityInfo.DNSNames) > 1 {
+			log.Printf("Additional configured hostnames: %s",
+				strings.Join(authorityInfo.DNSNames[1:], ", "))
+		}
 		for _, crt := range authorityInfo.RootX509Certs {
 			log.Printf("X.509 Root Fingerprint: %s", x509util.Fingerprint(crt))
 		}
 		if authorityInfo.SSHCAHostPublicKey != nil {
-			log.Printf("SSH Host CA Key: %s\n", authorityInfo.SSHCAHostPublicKey)
+			log.Printf("SSH Host CA Key is %s\n", authorityInfo.SSHCAHostPublicKey)
 		}
 		if authorityInfo.SSHCAUserPublicKey != nil {
 			log.Printf("SSH User CA Key: %s\n", authorityInfo.SSHCAUserPublicKey)