1

我想将 cosmos-auth 与 Idm GE 集成。node.js 应用程序的配置是:

{
"host": "192.168.4.180",
"port": 13000,
"private_key_file": "key.pem",
"certificate_file": "cert.pem",
"idm": {
  "host": "192.168.4.33",
  "port": "443",
  "path": "/oauth2/token"
},
"cosmos_app": {
  "client_id": "0434fdf60897479588c3c31cfc957b6d",
  "client_secret": "a7c3540aa5de4de3a0b1c52a606b82df"
},
"log": {
  "file_name": "/var/log/cosmos/cosmos-auth/cosmos-auth.log",
  "date_pattern": ".dd-MM-yyyy"
 }
}

当我将 HTTP POST 请求直接发送到 IDM GE 到 url

https://192.168.4.33:443/oauth2/token

使用所需的参数,我得到了好的结果:

{
 access_token: "LyZT5DRGSn0F8IKqYU8EmRFTLo1iPJ"
 token_type: "Bearer"
 expires_in: 3600
 refresh_token: "XiyfKCHrIVyludabjaCyGqVsTkx8Sf"
}

但是当我卷曲 cosmos-auth node.js 应用程序时

curl -X POST "https://192.168.4.180:13000/cosmos-auth/v1/token" -H 
"Content-Type: application/x-www-form-urlencoded" -d   
"grant_type=password&username=idm&password=idm" -k

我得到下一个结果:

{"statusCode":500,"error":"Internal Server Error","message":"An internal server error occurred"}

有没有人遇到过类似的事情?可能是什么问题呢?

4

1 回答 1

0

我犯的错误是使用未签名的证书。我多么笨拙。因此,要么签署证书,要么在选项对象中插入附加元素(rejectUnauthorized:false)

var options = {
    host : host,
    port : port,
    path : path,
    method : method,
    headers: headers,
    rejectUnauthorized: false
};

或在文件开头插入:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

当然,这只是临时解决方案,直到我们使用完全签名的证书。无论如何,cosmos-auth node.js 应用程序中的错误处理和日志应该显示更多。

于 2015-08-19T08:09:47.947 回答