ubuntu - 在 ubuntu ec2 的 couchdb 中设置自签名 ssl 证书时出现问题

标签 ubuntu ssl amazon-web-services amazon-ec2 couchdb

我正在尝试将我的电脑 (ubuntu 12.10) 中的相同环境复制到 aws ec2 (ubuntu 12.04)。

所以我执行了以下命令:

# openssl genrsa -out localhost.key 2048

# openssl req -new -x509 -key localhost.key -out localhost.crt -days 3650 -subj /CN=localhost

之后,我按如下方式配置 local.ini:(确保 couchdb 用户可以访问这些证书文件):

[daemons]
httpsd = {couch_httpd, start_link, [https]}

[ssl]
cert_file = /opt/couchdb/etc/cert/localhost.crt
key_file = /opt/couchdb/etc/cert/localhost.key

当我在我的电脑上运行这个命令时,它工作正常,

curl -v -k https://localhost:6984/

但在 aws ec2 上我收到以下错误:

* About to connect() to localhost port 6984 (#0)
*   Trying 127.0.0.1... connected
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* Unknown SSL protocol error in connection to localhost:6984 
* Closing connection #0
curl: (35) Unknown SSL protocol error in connection to localhost:6984 

沙发日志:

Mon, 30 Sep 2013 00:27:57 GMT] [error] [<0.3024.1>] {error_report,<0.61.0>,
                                   {<0.3024.1>,std_error,
                                    [83,83,76,58,32,"1095",58,32,"error",58,
                                     [123,
                                      ["try_clause",44,
                                       [123,["error",44,"eacces"],125]],
                                      125],
                                     32,
                                     "/usr/local/etc/couchdb/cert/localhost.crt",
                                     "\n",32,32,
                                     [91,
                                      [[123,
                                        ["ssl_manager",44,"cache_pem_file",44,
                                         "2"],
                                        125],
                                       44,10,"   ",
                                       [123,
                                        ["ssl_certificate",44,
                                         "file_to_certificats",44,"2"],
                                        125],
                                       44,10,"   ",
                                       [123,
                                        ["ssl_connection",44,
                                         "init_certificates",44,"6"],
                                        125],
                                       44,10,"   ",
                                       [123,
                                        ["ssl_connection",44,"ssl_init",44,
                                         "2"],
                                        125],
                                       44,10,"   ",
                                       [123,
                                        ["ssl_connection",44,"init",44,"1"],
                                        125],
                                       44,10,"   ",
                                       [123,
                                        ["gen_fsm",44,"init_it",44,"6"],
                                        125],
                                       44,10,"   ",
                                       [123,
                                        ["proc_lib",44,"init_p_do_apply",44,
                                         "3"],
                                        125]],
                                      93],
                                     "\n"]}}
[Mon, 30 Sep 2013 00:27:57 GMT] [error] [<0.3024.1>] {error_report,<0.61.0>,
                         {<0.3024.1>,crash_report,
                          [[{initial_call,
                                {ssl_connection,init,['Argument__1']}},
                            {pid,<0.3024.1>},
                            {registered_name,[]},
                            {error_info,
                                {exit,ecertfile,
                                    [{gen_fsm,init_it,6},
                                     {proc_lib,init_p_do_apply,3}]}},
                            {ancestors,[ssl_connection_sup,ssl_sup,<0.62.0>]},
                            {messages,[]},
                            {links,[<0.66.0>]},
                            {dictionary,[]},
                            {trap_exit,false},
                            {status,running},
                            {heap_size,2584},
                            {stack_size,24},
                            {reductions,1532}],
                           []]}}
[Mon, 30 Sep 2013 00:27:57 GMT] [error] [<0.66.0>] {error_report,<0.61.0>,
                       {<0.66.0>,supervisor_report,
                        [{supervisor,{local,ssl_connection_sup}},
                         {errorContext,child_terminated},
                         {reason,ecertfile},
                         {offender,
                             [{pid,<0.3024.1>},
                              {name,undefined},
                              {mfargs,{ssl_connection,start_link,undefined}},
                              {restart_type,temporary},
                              {shutdown,4000},
                              {child_type,worker}]}]}}
[Mon, 30 Sep 2013 00:27:57 GMT] [error] [<0.349.1>] {error_report,<0.31.0>,
                                  {<0.349.1>,std_error,
                                   [{application,mochiweb},
                                    "Accept failed error",
                                    "{error,ecertfile}"]}}
[Mon, 30 Sep 2013 00:27:57 GMT] [error] [<0.349.1>] {error_report,<0.31.0>,
                        {<0.349.1>,crash_report,
                         [[{initial_call,
                               {mochiweb_acceptor,init,
                                   ['Argument__1','Argument__2',
                                    'Argument__3']}},
                           {pid,<0.349.1>},
                           {registered_name,[]},
                           {error_info,
                               {exit,
                                   {error,accept_failed},
                                   [{mochiweb_acceptor,init,3},
                                    {proc_lib,init_p_do_apply,3}]}},
                           {ancestors,
                               [https,couch_secondary_services,
                                couch_server_sup,<0.32.0>]},
                           {messages,[]},
                           {links,[<0.2106.0>,#Port<0.3554>]},
                           {dictionary,[]},
                           {trap_exit,false},
                           {status,running},
                           {heap_size,987},
                           {stack_size,24},
                           {reductions,225918}],
                          []]}}
[Mon, 30 Sep 2013 00:27:57 GMT] [error] [<0.2106.0>] {error_report,<0.31.0>,
                         {<0.2106.0>,std_error,
                          {mochiweb_socket_server,310,
                              {acceptor_error,{error,accept_failed}}}}}

那么,请问如何解决这个问题?


更新:重要的是要说 mochiweb 无法访问我的证书的原因我运行 couchdb root 用户不是来自 couchdb 用户.

因此,每次都要确保您正在与 COUCHDB 用户一起运行您的程序

sudo -i -u couchdb couchdb

最佳答案

有了更新的问题。 CouchDB 无法访问证书。要么是因为文件丢失,要么是 CouchDB 没有这些文件的权限。

关于ubuntu - 在 ubuntu ec2 的 couchdb 中设置自签名 ssl 证书时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19081676/

相关文章:

python - pip3 无法在 ubuntu 20.04 : "has no attribute ' SourceFileLoader'"上运行

amazon-web-services - 使用 godaddy 域的 HTTPS 连接到 cloudfront/S3

mysql - EC2 实例 - Wordpress 数据库不断崩溃

java - aws.accessKeyId 和 aws.secretKey 未被读取

javascript - AWS Lambda 提前结束(没有任何明确的返回或回调)

python - 在 ubuntu 中运行 buildozer 时找不到 Git (git)

git - 在 Ubuntu 13.10 上降级 git

c++ - 如何在 C++ 和 Boost 中将数组参数传递给 TCP 客户端的函数

php - Apache 和 MySQL 无法在 xampp 控制面板上运行

node.js - 如何启用基于 NodeJS (Express) 的服务器的 SSL 连接