【问题标题】:How do we set 'expiration time', when we create new key with OpenPGP?当我们使用 OpenPGP 创建新密钥时,我们如何设置“过期时间”?
【发布时间】:2017-05-26 14:53:44
【问题描述】:

在 OpenPGP.js 中,我们有一个函数Key.prototype.getExpirationTime,它“返回主键的过期时间,如果键没有过期,则返回 null”: https://github.com/openpgpjs/openpgpjs/blob/master/src/key.js#L472

但是当我们创建新密钥时,我们如何设置这个过期时间呢? 我没有在这个函数 https://github.com/openpgpjs/openpgpjs/blob/master/src/key.js#L938 或它的文档中看到 https://openpgpjs.org/openpgpjs/doc/module-key.html '过期时间'参数

【问题讨论】:

    标签: javascript openpgp openpgp.js


    【解决方案1】:

    OpenPGP.js 这还没有实现,请参阅:https://github.com/openpgpjs/openpgpjs/issues/511#issuecomment-272376745

    目前我看到的最简单的解决方案是使用kbpgp.js 生成密钥,如下所示:https://ageyev.github.io/crypto/openpgp/ 它需要比 OpenPGP.js 更多的时间来生成密钥,但可以。

    【讨论】:

      【解决方案2】:

      就这么简单:

      let expires = 60 * 60 * 24 * 30 // seconds to expire keys {Number}
      let PGPOptions = {
          userIds: [{
              name: 'username',
              email: 'awesome@mail.com'
          }],
          numBits: 2048,                // RSA
          passphrase: 'good passphrase' // protects the private key
          keyExpirationTime: expires    // 30 days
      }
      // create keys (pub/priv)
      openpgp.generateKey(PGPOptions).then(key => {
          let privkey = key.privateKeyArmored,
              pubkey = key.publicKeyArmored
      })
      

      【讨论】:

        猜你喜欢
        • 2021-08-31
        • 1970-01-01
        • 2016-05-15
        • 2017-05-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-12-03
        • 2023-03-16
        相关资源
        最近更新 更多