我正在尝试读取加密的 PKCS8 私钥文件。我生成了这样的密钥:
openssl genrsa -out file.pem -passout pass:file -aes256 1024
openssl pkcs8 -topk8 -inform pem -in file.pem -outform pem -out filePKCS8.pem
Run Code Online (Sandbox Code Playgroud)
我尝试以这种方式在 Go 中阅读它:
block, _ := pem.Decode(key)
return x509.DecryptPEMBlock(block, password)
Run Code Online (Sandbox Code Playgroud)
但我收到一条错误消息:
x509: no DEK-Info header in block
Run Code Online (Sandbox Code Playgroud)
但是,我无法弄清楚出了什么问题。我生成的密钥错误还是使用了错误的库?我看到专门用于读取未加密 PKCS8 文件的库,但没有专门用于加密 PKCS8 文件的库。
有谁有想法吗?
我正在使用node.js,并使用集群模块.每次我运行cluster.fork(),我总是得到一个
throw er; // Unhandled 'error' event
Error: bind EADDRINUSE
at exports._errnoException (util.js:746:11)
at cb (net.js:1205:33)
at rr (cluster.js:592:14)
at Worker.<anonymous> (cluster.js:563:9)
at process.<anonymous> (cluster.js:692:8)
at process.emit (events.js:129:20)
at handleMessage (child_process.js:324:10)
at Pipe.channel.onread (child_process.js:352:11)
Run Code Online (Sandbox Code Playgroud)
我一直在谷歌搜索,我不知道这是怎么回事,因为我没有传递任何端口号码.
谢谢
编辑:发布代码
var setupWorkers = function() {
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < 5; i++) {
cluster.fork();
}
}
Run Code Online (Sandbox Code Playgroud)
这是在我通过调用节点app.js运行的app.js中调用的函数
我在https://golang.org/pkg/crypto/x509/中的证书功能中找不到它
但是,如何从Go中的证书获取https://golang.org/pkg/crypto/rsa/#PublicKey中定义的公钥?
x509v3 中 AuthorityInfoAccess 字段是必需的吗?我有一些证书,我正在尝试进行 OCSP 验证,但当我这样做时他们似乎没有这个字段
openssl x509 -in file.cer -inform DER -text -noout
Run Code Online (Sandbox Code Playgroud)
我想知道它是否不在该输出中是否意味着它不存在?
我是一个巨大的承诺链,但是我意识到其中一个函数返回一个具有侦听器并对回调做出反应的对象,例如
object.on('data', function(err, data) {
//do something
});
object.on('exit', function(err, data) {
//do something
});
Run Code Online (Sandbox Code Playgroud)
我想知道是否有办法使用 Promise 来解决这个问题并将它们变成 thenables。除了重写我的整个 Promise 链以使用回调之外,还有没有其他选择?
go ×2
node.js ×2
cryptography ×1
encryption ×1
javascript ×1
listeners ×1
master-slave ×1
ocsp ×1
openssl ×1
promise ×1
public-key ×1
rsa ×1
x509 ×1