- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
情况是这样的。我创建了一个自签名 CA 证书,并用它来签署第二个用于 https 的证书。 Web 服务器是 nginx,对 expressjs 应用程序执行 SSL 终止和反向代理。为了验证信任链是否正确,我在 Firefox 中安装了 CA,并且能够按预期通过 https 访问该网站而没有警告。此外,我可以使用 openssl x509 -in server.crt -text -noout
检查服务器的证书,我可以看到预期的颁发者,尤其是主题的预期通用名称。 (注意:此处使用的通用名称是 IP 地址,以防出现问题。)
但是,当我尝试使用 requestjs 通过 nodejs 脚本访问服务器时,事情并没有那么顺利。在脚本中,使用如下代码加载 CA 证书:
request.get({url: theUrl, ca: fs.readFileSync("./ca.crt")}, ...
但是我得到了这个错误(为了便于阅读而换行,原来是一行):
Contacting doorman failed: Error: Hostname/IP doesn't match certificate's altnames:
"IP: <redacted> is not in the cert's list: "
特别可疑的是,它似乎在说“证书列表”是空的。在其他答案中建议在选项中使用 rejectUnauthorized: false
,但这不是这个应用程序的好选择,因为我想进行身份验证。
如何让 requestjs/nodejs 信任这个证书?
服务器证书的内容,由 openssl x509 -text
报告
Certificate:
Data:
Version: 1 (0x0)
Serial Number: 3 (0x3)
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, ST=State, L=City, O=Company, CN=www.company.com
Validity
Not Before: Dec 7 17:19:51 2015 GMT
Not After : Oct 14 17:19:51 2025 GMT
Subject: C=US, ST=State, L=City, O=Company, CN=1.2.3.4/emailAddress=webmaster@company.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (4096 bit)
Modulus:
...
Exponent: 65537 (0x10001)
Signature Algorithm: sha256WithRSAEncryption
...
以及用于生成该证书的配置文件:
[ req ]
default_bits = 4096
prompt = no
encrypt_key = no
distinguished_name = req_distinguished_name
req_extensions = v3_req
[ req_distinguished_name ]
countryName = "US"
stateOrProvinceName = "State"
localityName = "City"
organizationName = "Company"
commonName = "1.2.3.4"
emailAddress = "webmaster@company.com"
[ v3_req ]
subjectAltName = IP:1.2.3.4
最佳答案
Hostname/IP doesn't match certificate's altnames:
我的猜测是您的证书包含在 URL 中仅用作主题 (CN) 而不是主题备用名称 (SAN) 的正确主机名,但它包含其他名称作为 SAN。该标准非常明确,如果给出了任何主题替代 DNS 名称,则不应检查 CN,但大多数浏览器无论如何都会检查 CN(我认为 Safari 更严格)。但是 node.js 实现了严格的行为,因此会失败。
如果我的猜测是正确的(没有证书很难看清),那么必须通过创建正确的证书来解决问题。另一种可能性是您在浏览器和 nodejs 中使用了稍微不同的 URL(比如有和没有 www
前缀)。
编辑:在看到您实际使用的证书后......
您有一个 IP 地址在 CN 中的证书。虽然这也被大多数浏览器支持,但这是不对的。 IP 地址必须作为 ipadress SAN 条目而不是 CN 给出。 Nodejs 只希望它在那里,我认为 Safari 也那么严格。请注意,对于 IE,您必须将其放入 CN 或作为 dnsname SAN 条目,因为它们在这种情况下也喜欢违反标准。因此为了安全起见,将其作为 ipaddress、dnsname,也可能作为 CN。
关于node.js - 为什么 requestjs 拒绝适用于 Firefox 的自签名 SSL 证书?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34138384/
我在我的 Xcode 项目目录中输入了以下内容: keytool -genkey -v -keystore release.keystore -alias mykey -keyalg RSA \
假设我有一个像这样的 DataFrame(或 Series): Value 0 0.5 1 0.8 2 -0.2 3 None 4 None 5 None
我正在对一个 Pandas 系列进行相对繁重的应用。有什么方法可以返回一些打印反馈,说明每次调用函数时在函数内部进行打印还有多远? 最佳答案 您可以使用跟踪器包装您的函数。以下两个示例,一个基于完成的
我有一个 DataFrame,其中一列包含列表作为单元格内容,如下所示: import pandas as pd df = pd.DataFrame({ 'col_lists': [[1, 2
我想使用 Pandas df.apply 但仅限于某些行 作为一个例子,我想做这样的事情,但我的实际问题有点复杂: import pandas as pd import math z = pd.Dat
我有以下 Pandas 数据框 id dist ds 0 0 0 0 5 1 0 0 7 2 0 0
这发生在我尝试使用 Gradle 构建时。由于字符串是对象,因此似乎没有理由发生此错误: No signature of method: java.util.HashMap.getOrDefault(
您好,有人可以解释为什么在 remaining() 函数中的 Backbone 示例应用程序 ( http://backbonejs.org/examples/todos/index.html ) 中
我有两个域类:用户 class User { String username String password String email Date dateCreated
问题陈述: 一个 pandas dataframe 列系列,same_group 需要根据两个现有列 row 和 col 的值从 bool 值创建。如果两个值在字典 memberships 中具有相似
apporable 报告以下错误: error: unknown type name 'MKMapItem'; did you mean 'MKMapView'? MKMapItem* destina
我有一个带有地址列的大型 DataFrame: data addr 0 0.617964 IN,Krishnagiri,635115 1 0.635428 IN,Chennai
我有一个列表list,里面有这样的项目 ElementA: Number=1, Version=1 ElementB: Number=1, Version=2 ElementC: Number=1,
我正在编译我的源代码,它只是在没有运行应用程序的情况下终止。这是我得到的日志: Build/android-armeabi-debug/com.app4u.portaldorugby/PortalDo
我正在尝试根据另一个单元格的值更改单元格值(颜色“红色”或“绿色”)。我运行以下命令: df.loc[0, 'Colour'] = df.loc[0, 'Count'].apply(lambda x:
我想弄清楚如何使用 StateT结合两个 State基于对我的 Scalaz state monad examples 的评论的状态转换器回答。 看来我已经很接近了,但是在尝试申请 sequence
如果我已经为它绑定(bind)了集合,我该如何添加 RibbonLibrary 默认的快速访问项容器。当我从 UI 添加快速访问工具项时,它会抛出 Operation is not valid whi
在我学习期间Typoclassopedia我遇到了这个证明,但我不确定我的证明是否正确。问题是: One might imagine a variant of the interchange law
我是一名优秀的程序员,十分优秀!