gpt4 book ai didi

node.js - 哪些文件用于带有 passport-saml 的 SAML

转载 作者:太空宇宙 更新时间:2023-11-03 14:06:26 25 4
gpt4 key购买 nike

我正在尝试将 SAML 与 node.js 和 passport-saml 模块一起使用,但我不知道应该使用哪个证书/ key 。

我有这些文件:

  • 我的域名.crt
  • 我的域名.key
  • 中级CA.crt

我需要设置decryptionPvkdecryptionCertprivateCert

var samlStrategy = new passportSaml.Strategy({
//--- URL that goes from the Identity Provider -> Service Provider
callbackUrl : 'http://mydomain/login/callback',

//--- URL that goes from the Service Provider -> Identity Provider
entryPoint : 'https://auth.samlserver',

issuer : sails.config.passport.issuer,

//--- Identity Provider's Public Key
cert : sails.config.passport.cert,

//--- Service Provider Certificate
privateCert : fs.readFileSync('./certificats/mydomain.crt', 'utf-8'), // same error with IntermediateCA.crt

//--- Service Provider private key
decryptionPvk : fs.readFileSync('./certificats/mydomain.key', 'utf-8'),
logoutUrl : 'https://auth.samlserver/logout',
passReqToCallback : true,
},
(req, profile, done) => {
console.log('profile :', profile);
return done();
});

对于路由/元数据(使用decryptionCert):

samlStrategy.generateServiceProviderMetadata(fs.readFileSync('./certificats/mydomain.crt', 'utf-8'))

但是我有以下错误信息:

crypto.js:279
var ret = this._handle.sign(toBuf(key), null, passphrase);
^

Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Sign.sign (crypto.js:279:26)
at [object Object].SAML.signRequest (C:\Users\mseron\Documents\dev\node\mysite\node_modules\passport-saml\lib\passport-saml\saml.js:135:34)
at requestToUrlHelper (C:\Users\mseron\Documents\dev\node\mysite\node_modules\passport-saml\lib\passport-saml\saml.js:308:12)
at DeflateRaw.onEnd (zlib.js:227:5)
at emitNone (events.js:85:20)
at DeflateRaw.emit (events.js:179:7)
at endReadableNT (_stream_readable.js:913:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)

最佳答案

实际上,对于mydomain.key,错误信息是

Error: error:0906A068:PEM routines:PEM_do_header:bad password read

我需要使用 mydomain.key 及其密码

在 node.js 中

var samlStrategy = new passportSaml.Strategy({
...

//--- Service Provider Certificate
privateCert : {
key : fs.readFileSync('./certificats/mydomain.key', 'utf-8'),
passphrase : 'strong passphrase'
},
...
},
(req, profile, done) => {
...
});

关于node.js - 哪些文件用于带有 passport-saml 的 SAML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40622251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com