- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我从证书颁发机构获得了这些文件:
我尝试了这个小代码:
var express = require('express');
var app = express();
var fs = require("fs");
var https = require('https');
var privateKey = fs.readFileSync('domain.com.p7b').toString();
var certificate = fs.readFileSync('domain.com.crt').toString();
var ca_bundle = fs.readFileSync('domain.com.ca-bundle').toString();
var credentials = { key: privateKey,
ca : ca_bundle,
cert: certificate};
https.createServer(credentials,app).listen(8080, function () {
console.log('Example app listening on port 8080!');
});
启动脚本后,出现以下错误:
(err): at Object.createSecureContext (_tls_common.js:87:19)
(err): at Server (_tls_wrap.js:721:25)
(err): at new Server (https.js:17:14)
(err): at Object.exports.createServer (https.js:37:10)
(err): at Object.<anonymous> (/utec_temp/https/web.js:27:7)
(err): at Module._compile (module.js:435:26)
(err): at Object.Module._extensions..js (module.js:442:10)
(err): at Module.load (module.js:356:32)
(err): at Function.Module._load (module.js:311:12)
(err): Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
(err): at Error (native)
(err): at Object.createSecureContext (_tls_common.js:87:19)
(err): at Server (_tls_wrap.js:721:25)
(err): at new Server (https.js:17:14)
(err): at Object.exports.createServer (https.js:37:10)
(err): at Object.<anonymous> (/utec_temp/https/web.js:27:7)
(err): at Module._compile (module.js:435:26)
(err): at Object.Module._extensions..js (module.js:442:10)
(err): at Module.load (module.js:356:32)
(err): at Function.Module._load (module.js:311:12)
google 上的所有示例都使用自签名证书,但是当我需要在真实环境中工作时会发生什么?
我的小代码在开发中使用自签名 key ,按照这个例子:
我研究了一下,发现了这个:
但我无法更正错误。
我也减少到一个文件:
var credentials = {cert: certificate};
错误是一样的。所以我认为当我将这些证书从 Windows 移动到 Unix 时可能是格式错误。我用了dos2unix工具,报错也是一样。
我的 Node 版本是4.4.7
感谢任何帮助。
提前致谢!
最佳答案
我来晚了,但我希望这对您有所帮助。
如果有人使用这些文件:pb7、crt、ca-bundle 并遇到此错误:
error:0906D06C:PEM routines:PEM_read_bio:no start line
这意味着这些文件是错误的、损坏的或者是为其他环境(例如 Windows)请求的,正如这篇文章所说:https://serverfault.com/a/317038
因此,在我的案例中,解决方案是申请新证书,在规范中,我添加了以下内容:
同样重要的是保存用于创建 csr 的私钥并将其发送给证书提供商(我调用了 initial.key)。
示例 http://www.backwardcompatible.net/155-Setting-up-real-SSL-Nodejs-Express
最后,您的提供商将向您发送一个包含多个文件的压缩包。您的 Node 应用程序只需要一个 .crt 文件:
var privateKey = fs.readFileSync('/some/folder/initial.key').toString();
var certificate = fs.readFileSync('/some/folder/certificate.crt').toString();
var credentials = {key: privateKey, cert: certificate};
注意:certificate.ca-bundle 和 certificate.crt 文件必须由证书提供商发送。
当您使用 https 证书、域或子域时,您不应直接使用证书或配置应用程序。
Node.js、java、python 和其他语言都有使用https 发布安全端点的库。这是通过手动加载您购买的或自签名的证书来实现的。 这可行,但这应该是最后的选择。
例如:开发团队在启动应用程序时会遇到问题,因为源代码直接需要证书和其他配置。测试部署需要特定的证书等
对于干净、可维护和可扩展的架构,并遵循模式 separation of concerns (SoC) 不要修改您的源代码并将这项工作或复杂性留给 apache、nginx、haproxy、aws elb 或某些负载均衡器。
这里有一些关于如何在另一层而不是在应用程序中启用 https 的示例:
apache 2.2 示例
SSLCertificateFile /some/folder/certificate.crt
SSLCertificateKeyFile /some/folder/initial.key
SSLCertificateChainFile /some/folder/certificate.ca-bundle
nginx 示例
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/your_domain_name.pem; (or bundle.crt)
ssl_certificate_key /etc/ssl/your_domain_name.key;
server_name your.domain.com;
...
}
这种复杂性必须对开发团队透明,并且应该由系统管理员、基础架构或与贵公司网络相关的其他团队管理。
关于Node.js https pem 错误 : error:0906D06C:PEM routines:PEM_read_bio:no start line,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38215083/
有没有更简单的方法是 JavaScript: if (routine !== null && routine.exercises !== undefined && routine.exerci
在我们的软件中,我们不断收到此警告/错误消息。不确定此消息的显示方式/原因。 HTTP asio handshake failed: error:140000DB:SSL routines:SSL r
我正在阅读有关 gobyexample 的教程。我注意到作者已经展示了使用 go routine 的 gochannel 示例,但在错误的 go channel 中他直接向 channel 发送消息。
我们的 Application.cfc 中有以下代码: 在 error.cfm 页面中,我们有以下代码(我没有写): function G
我正在学习 lisp 语言(做 lisp 例程),在一般情况下我知道什么是例程,但在技术上下文中我可以谈论它,因为我现在开始学习例程。那么,例行公事的真正定义是什么?(我已经用谷歌搜索过这个,但没有找
我想创建数据库 (MySQL) 的完整备份,我使用以下命令: mysqldump --routines -u dev_user -pblabla MyDB > d:\DB_Backups\%date%
我正在尝试编写一个应用程序来下载一系列图像。 130 张 116kb 图片(作品) 50 张 500kb 图片(作品) 130 张 500kb 的图片(最终挂起) 230 张 116kb 图片(最终挂
各位,我是 golang 的新手。我想从我的 application.cuz 回滚机制生成的日志文件中获取数据,我遇到了一些问题。例如,我的目标日志文件是 chats.log ,它将重命名为 chat
所以我正在尝试实现一个简单地监听 Redis 订阅的 go 例程(我为此使用 Go-redis 库)然后发送消息在接收/处理 redis 消息后在 channel 上。 像这样: func foo(r
我正在做 Web Crawler围棋之旅的问题。到目前为止,这是我的解决方案: func GatherUrls(url string, fetcher Fetcher) []string {
我刚开始学习 Go,所以请耐心等待,我尝试使用 Go 例程和 channel ,但不知何故遇到了僵局。 举个例子 package main import ( "fmt" "sync"
我是 Go 的新手,我在 Heroku 的应用程序中使用 Go 例程,这些例程很长(最多 7 分钟),并且不能被打断。我看到自动定标器有时会杀死运行例程的 Heroku dyno。我需要一种独立于测功
如何获取最后一个(理想情况下)go 例程(该应用程序有多个 go 例程)的堆栈跟踪,该例程发生 panic 并恢复并仅记录了一条不多的描述性错误消息?不知道哪个套路恢复了。另外,请记住我不会更改任何导
令我惊讶的是,go 例程似乎完美地交错......看到这个之后,我开始相信我还没有了解一些关于内部的缺失信息。示例: $ go run x.go > output $ grep ping output
TL;DR 接受并连接两个独立的 SETS 连接。想用 RPC 并发完成。 我正在尝试在我的计算机上创建半分布式系统。我现在正在处理的这段代码有点像代理节点,换句话说,它总是从一个端口接受客户端连接。
此问题的一个示例是当用户创建资源并删除资源时。我们将执行该操作并增加(减少)计数器缓存。 在测试中,有时会出现计数器缓存未被 go 例程更新的竞争条件。 编辑:抱歉造成混淆,澄清一下:计数器缓存不在内
我有一个关于 go routines 的问题。 我的代码: func main() { ok := make(chan bool, 1) i := 0 fmt.Println(
我想运行多个 Go 例程。我希望他们都同时启动。我添加了另一个同步 waitGroup 并在 go 例程的开始处添加了一个等待。然而,这并不能同时启动所有的 go 例程。我应该怎么做才能让多个 go
var m *sync.RWMutex func main() { m = new(sync.RWMutex) n := 100 go func() { for
1、如果用户有create routine 权限那么他就可以创建procedure | function 。 2、如果用户创建了procedure | function 那么mysql 会自动赋予
我是一名优秀的程序员,十分优秀!