예제 #1
0
파일: main.go 프로젝트: hlandau/acme
func cmdCull() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	err = storageops.Cull(s, *cullSimulateFlag)
	log.Fatale(err, "cull")
}
예제 #2
0
파일: main.go 프로젝트: hlandau/acme
func cmdImportKey() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	err = importKey(s, *importKeyArg)
	log.Fatale(err, "import key")
}
예제 #3
0
파일: main.go 프로젝트: hlandau/acme
func cmdReconcile() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	err = storageops.Reconcile(s)
	log.Fatale(err, "reconcile")
}
예제 #4
0
파일: main.go 프로젝트: pcarrier/acme
func cmdWant() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	alreadyExists := false
	s.VisitTargets(func(t *storage.Target) error {
		nm := map[string]struct{}{}
		for _, n := range t.Satisfy.Names {
			nm[n] = struct{}{}
		}

		for _, w := range *wantArg {
			if _, ok := nm[w]; !ok {
				return nil
			}
		}

		alreadyExists = true
		return nil
	})

	if alreadyExists {
		return
	}

	tgt := storage.Target{
		Satisfy: storage.TargetSatisfy{
			Names: *wantArg,
		},
	}

	err = s.SaveTarget(&tgt)
	log.Fatale(err, "add target")
}
예제 #5
0
파일: main.go 프로젝트: hlandau/acme
func cmdUnwant() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	for _, hn := range *unwantArg {
		err = storageops.RemoveTargetHostname(s, hn)
		log.Fatale(err, "remove target hostname ", hn)
	}
}
예제 #6
0
파일: main.go 프로젝트: hlandau/acme
func cmdStatus() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	info := StatusString(s)
	log.Fatale(err, "status")

	fmt.Print(info)
}
예제 #7
0
파일: main.go 프로젝트: hlandau/acme
func revokeByCertificateID(certID string) {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	err = storageops.RevokeByCertificateOrKeyID(s, certID)
	log.Fatale(err, "revoke")

	err = storageops.Reconcile(s)
	log.Fatale(err, "reconcile")
}
예제 #8
0
파일: main.go 프로젝트: hlandau/acme
func cmdAccountThumbprint() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	s.VisitAccounts(func(a *storage.Account) error {
		thumbprint, _ := acmeutils.Base64Thumbprint(a.PrivateKey)
		fmt.Printf("%s\t%s\n", thumbprint, a.ID())
		return nil
	})
}
예제 #9
0
파일: main.go 프로젝트: hlandau/acme
func determineWebroot() string {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	webrootPaths := s.DefaultTarget().Request.Challenge.WebrootPaths
	if len(webrootPaths) > 0 {
		return webrootPaths[0]
	}

	return responder.StandardWebrootPath
}
예제 #10
0
파일: le-import.go 프로젝트: pcarrier/acme
func cmdImportLE() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	lePath := *importLEArg
	accountNames, err := getLEAccountNames(lePath)
	log.Fatale(err, "cannot inspect accounts directory - do you have permissions to read the Let's Encrypt directory (i.e. are you root)?")

	// In order to import a Let's Encrypt state directory, we must:
	//   - import the account keys
	//   - import the certificate keys
	//   - import the certificates

	// Import account keys.
	durls := map[string]struct{}{}

	for _, accountName := range accountNames {
		acct, err := importLEAccount(s, lePath, accountName)
		log.Fatale(err, "import account")

		durls[acct.DirectoryURL] = struct{}{}
	}

	keyFiles, err := filepath.Glob(filepath.Join(lePath, "keys", "*.pem"))
	log.Fatale(err)

	// Import certificate keys.
	for _, keyFile := range keyFiles {
		err := importKey(s, keyFile)
		log.Fatale(err, "import key")
	}

	// Import certificates.
	certFiles, err := filepath.Glob(filepath.Join(lePath, "archive", "*", "cert*.pem"))
	log.Fatale(err)

	for _, certFile := range certFiles {
		err := importCert(s, certFile)
		log.Fatale(err, "import certificate")
	}

	// If there is no default provider set, and we have only one directory URL
	// imported, set it as the default provider.
	if len(durls) == 1 && s.DefaultTarget().Request.Provider == "" {
		for p := range durls {
			s.DefaultTarget().Request.Provider = p
			err := s.SaveTarget(s.DefaultTarget())
			log.Fatale(err, "couldn't set default provider")
			break
		}
	}
}
예제 #11
0
파일: main.go 프로젝트: falkbizz/acme
func cmdWant() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	tgt := storage.Target{
		Satisfy: storage.TargetSatisfy{
			Names: *wantArg,
		},
	}

	err = s.SaveTarget(&tgt)
	log.Fatale(err, "add target")
}
예제 #12
0
파일: main.go 프로젝트: hlandau/acme
func cmdWant() {
	hostnames := *wantArg

	// Ensure all hostnames provided are valid.
	for idx := range hostnames {
		norm, err := acmeutils.NormalizeHostname(hostnames[idx])
		if err != nil {
			log.Fatalf("invalid hostname: %#v: %v", hostnames[idx], err)
			return
		}
		hostnames[idx] = norm
	}

	// Determine whether there already exists a target satisfying all given
	// hostnames or a superset thereof.
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	alreadyExists := false
	s.VisitTargets(func(t *storage.Target) error {
		nm := map[string]struct{}{}
		for _, n := range t.Satisfy.Names {
			nm[n] = struct{}{}
		}

		for _, w := range hostnames {
			if _, ok := nm[w]; !ok {
				return nil
			}
		}

		alreadyExists = true
		return nil
	})

	if alreadyExists {
		return
	}

	// Add the target.
	tgt := storage.Target{
		Satisfy: storage.TargetSatisfy{
			Names: hostnames,
		},
	}

	err = s.SaveTarget(&tgt)
	log.Fatale(err, "add target")
}
예제 #13
0
파일: main.go 프로젝트: hlandau/acme
func cmdImportPEMAccount() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	f, err := os.Open(*importPEMPathArg)
	log.Fatale(err, "cannot open private key file")
	defer f.Close()

	b, err := ioutil.ReadAll(f)
	log.Fatale(err, "cannot read file")

	pk, err := acmeutils.LoadPrivateKey(b)
	log.Fatale(err, "cannot parse private key")

	_, err = s.ImportAccount(*importPEMURLArg, pk)
	log.Fatale(err, "cannot import account key")
}
예제 #14
0
파일: main.go 프로젝트: hlandau/acme
func cmdImportJWKAccount() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	f, err := os.Open(*importJWKPathArg)
	log.Fatale(err, "cannot open private key file")
	defer f.Close()

	b, err := ioutil.ReadAll(f)
	log.Fatale(err, "cannot read file")

	k := jose.JsonWebKey{}
	err = k.UnmarshalJSON(b)
	log.Fatale(err, "cannot unmarshal key")

	_, err = s.ImportAccount(*importJWKURLArg, k.Key)
	log.Fatale(err, "cannot import account key")
}
예제 #15
0
파일: le-import.go 프로젝트: falkbizz/acme
func cmdImportLE() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	lePath := *importLEArg
	accountNames, err := getLEAccountNames(lePath)
	log.Fatale(err, "cannot inspect accounts directory - do you have permissions to read the Let's Encrypt directory (i.e. are you root)?")

	// In order to import a Let's Encrypt state directory, we must:
	//   - import the account keys
	//   - import the certificate keys
	//   - import the certificates

	// Import account keys.
	for _, accountName := range accountNames {
		err := importLEAccount(s, lePath, accountName)
		log.Fatale(err, "import account")
	}

	keyFiles, err := filepath.Glob(filepath.Join(lePath, "keys", "*.pem"))
	log.Fatale(err)

	// Import certificate keys.
	for _, keyFile := range keyFiles {
		err := importKey(s, keyFile)
		log.Fatale(err, "import key")
	}

	// Import certificates.
	certFiles, err := filepath.Glob(filepath.Join(lePath, "archive", "*", "cert*.pem"))
	log.Fatale(err)

	for _, certFile := range certFiles {
		err := importCert(s, certFile)
		log.Fatale(err, "import certificate")
	}
}
예제 #16
0
파일: quickstart.go 프로젝트: pcarrier/acme
func cmdQuickstart() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	serverURL := promptServerURL()
	s.DefaultTarget().Request.Provider = serverURL
	err = s.SaveTarget(s.DefaultTarget())
	log.Fatale(err, "set provider URL")

	// key type
	keyType := promptKeyType()
	switch keyType {
	case "rsa":
		s.DefaultTarget().Request.Key.Type = "rsa"
		rsaKeySize := promptRSAKeySize()
		if rsaKeySize != 0 {
			s.DefaultTarget().Request.Key.RSASize = rsaKeySize
			err = s.SaveTarget(s.DefaultTarget())
			log.Fatale(err, "set preferred RSA Key size")
		}
	case "ecdsa":
		s.DefaultTarget().Request.Key.Type = "ecdsa"
		ecdsaCurve := promptECDSACurve()
		if ecdsaCurve != "" {
			s.DefaultTarget().Request.Key.ECDSACurve = ecdsaCurve
			err = s.SaveTarget(s.DefaultTarget())
			log.Fatale(err, "set preferred ECDSA curve")
		}
	}

	// hook method
	method := promptHookMethod()
	var webroot []string
	switch method {
	case "webroot":
		webroot = []string{promptWebrootDir()}
	}

	if len(webroot) != 0 {
		err = os.MkdirAll(webroot[0], 0755)
		log.Fatale(err, "couldn't create webroot path")
	}

	s.DefaultTarget().Request.Challenge.WebrootPaths = webroot
	err = s.SaveTarget(s.DefaultTarget())
	log.Fatale(err, "set webroot path")

	prog, err := interaction.Auto.Status(&interaction.StatusInfo{
		Title: "Registering account...",
	})
	log.Fatale(err, "status")
	prog.SetProgress(0, 1)

	err = storageops.EnsureRegistration(s)
	log.Fatale(err, "couldn't complete registration")

	prog.SetProgress(1, 1)
	prog.Close()

	if method == "redirector" {
		promptSystemd()
	}

	installDefaultHooks()
	if promptInstallCombinedHooks() {
		installCombinedHooks()
	}

	promptCron()
	promptGettingStarted()
}