当前位置: 首页>>代码示例>>Golang>>正文


Golang storage.NewFDB函数代码示例

本文整理汇总了Golang中github.com/hlandau/acme/storage.NewFDB函数的典型用法代码示例。如果您正苦于以下问题:Golang NewFDB函数的具体用法?Golang NewFDB怎么用?Golang NewFDB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewFDB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: cmdCull

func cmdCull() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	err = storageops.Cull(s, *cullSimulateFlag)
	log.Fatale(err, "cull")
}
开发者ID:hlandau,项目名称:acme,代码行数:7,代码来源:main.go

示例2: cmdImportKey

func cmdImportKey() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	err = importKey(s, *importKeyArg)
	log.Fatale(err, "import key")
}
开发者ID:hlandau,项目名称:acme,代码行数:7,代码来源:main.go

示例3: cmdReconcile

func cmdReconcile() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

	err = storageops.Reconcile(s)
	log.Fatale(err, "reconcile")
}
开发者ID:hlandau,项目名称:acme,代码行数:7,代码来源:main.go

示例4: cmdWant

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")
}
开发者ID:pcarrier,项目名称:acme,代码行数:34,代码来源:main.go

示例5: cmdUnwant

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)
	}
}
开发者ID:hlandau,项目名称:acme,代码行数:9,代码来源:main.go

示例6: cmdStatus

func cmdStatus() {
	s, err := storage.NewFDB(*stateFlag)
	log.Fatale(err, "storage")

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

	fmt.Print(info)
}
开发者ID:hlandau,项目名称:acme,代码行数:9,代码来源:main.go

示例7: revokeByCertificateID

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")
}
开发者ID:hlandau,项目名称:acme,代码行数:10,代码来源:main.go

示例8: cmdAccountThumbprint

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
	})
}
开发者ID:hlandau,项目名称:acme,代码行数:10,代码来源:main.go

示例9: determineWebroot

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
}
开发者ID:hlandau,项目名称:acme,代码行数:11,代码来源:main.go

示例10: cmdImportLE

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
		}
	}
}
开发者ID:pcarrier,项目名称:acme,代码行数:52,代码来源:le-import.go

示例11: cmdWant

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")
}
开发者ID:falkbizz,项目名称:acme,代码行数:13,代码来源:main.go

示例12: cmdWant

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")
}
开发者ID:hlandau,项目名称:acme,代码行数:49,代码来源:main.go

示例13: cmdImportPEMAccount

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")
}
开发者ID:hlandau,项目名称:acme,代码行数:17,代码来源:main.go

示例14: cmdImportJWKAccount

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")
}
开发者ID:hlandau,项目名称:acme,代码行数:18,代码来源:main.go

示例15: cmdImportLE

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")
	}
}
开发者ID:falkbizz,项目名称:acme,代码行数:37,代码来源:le-import.go


注:本文中的github.com/hlandau/acme/storage.NewFDB函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。