本文整理匯總了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")
}
示例2: cmdImportKey
func cmdImportKey() {
s, err := storage.NewFDB(*stateFlag)
log.Fatale(err, "storage")
err = importKey(s, *importKeyArg)
log.Fatale(err, "import key")
}
示例3: cmdReconcile
func cmdReconcile() {
s, err := storage.NewFDB(*stateFlag)
log.Fatale(err, "storage")
err = storageops.Reconcile(s)
log.Fatale(err, "reconcile")
}
示例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")
}
示例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)
}
}
示例6: cmdStatus
func cmdStatus() {
s, err := storage.NewFDB(*stateFlag)
log.Fatale(err, "storage")
info := StatusString(s)
log.Fatale(err, "status")
fmt.Print(info)
}
示例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")
}
示例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
})
}
示例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
}
示例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
}
}
}
示例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")
}
示例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")
}
示例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")
}
示例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")
}
示例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")
}
}