【问题标题】:How to install SSL certificate in Vapor web framework?如何在 Vapor Web 框架中安装 SSL 证书?
【发布时间】:2016-09-27 09:42:01
【问题描述】:

我想安装 SSL(Comodo 通配符证书,例如:“*.test.com”) 在 Vapor Web 框架中,我得到的“servers.json”是:

{
    "default": {
        "port": "$PORT:443",
        "host": "api.test.com",
        "securityLayer": "tls",
        "tls": {
            "certificates": "chain",
            "certificateFile": "/path/ssl-bundle.crt",
            "chainFile": "/path/ssl-bundle.crt",
            "privateKeyFile": "/path/key.pem",
            "signature": "signedFile",
            "caCertificateFile": "/path/AddTrustExternalCARoot.crt"
            }
    }
}

我已经使用 openssl 命令确保“公共/私人”密钥匹配。关于“ssl-bundle.crt”之类的certificateFile部分,我也尝试了“*.test.com.crt”和“key.pem”(仍然使用openssl通过验证,唯一的区别是测试.com的证书,另一个是捆绑证书,已通过正确的订单组合。)。此外,所有证书和密钥的格式也是正确的。而且我还确保证书/密钥文件的位置正确,以便 Vapor 可以找到这些文件。但我仍然无法正确启动服务器,并且总是显示错误。 我尝试在 xcode 中找到确切的位置,但我只能看到它在这种方法中失败:“tls_accept_fds()”,它位于 CLibreSSL 库的 tls_server.c 中。

另外,我看到了 xcode 向我显示的错误消息:

使用debug模式跟踪后,我只能知道程序似乎在“SSL_set_rfd()”或“SSL_set_rfd()”中抛出错误,但我不知道具体。 xcode 只向我显示这个,我在调试控制台中找不到任何其他错误消息。结果,到目前为止我只能确保错误应该在这个块中:

int
tls_accept_fds(struct tls *ctx, struct tls **cctx, int fd_read, int fd_write)
{
struct tls *conn_ctx = NULL;

// I pass this block
if ((ctx->flags & TLS_SERVER) == 0) {
    tls_set_errorx(ctx, "not a server context");
    goto err;
}

// I pass this block
if ((conn_ctx = tls_server_conn(ctx)) == NULL) {
    tls_set_errorx(ctx, "connection context failure");
    goto err;
}

// I pass this block
if ((conn_ctx->ssl_conn = SSL_new(ctx->ssl_ctx)) == NULL) {
    tls_set_errorx(ctx, "ssl failure");
    goto err;
}

// I pass this block
if (SSL_set_app_data(conn_ctx->ssl_conn, conn_ctx) != 1) {
    tls_set_errorx(ctx, "ssl application data failure");
    goto err;
}

// The error occurs here, in SSL_set_rfd or SSL_set_wfd, it will then go to err part: "*cctx = NULL;", not even go into the if block.
if (SSL_set_rfd(conn_ctx->ssl_conn, fd_read) != 1 ||
    SSL_set_wfd(conn_ctx->ssl_conn, fd_write) != 1) {
    tls_set_errorx(ctx, "ssl file descriptor failure");
    goto err;
}

*cctx = conn_ctx;

return (0);

err:
tls_free(conn_ctx);

*cctx = NULL;

return (-1);
}

所以,以上是我现在得到的所有信息,我已经好几天在互联网上找不到解决方案了...... 谁能给我有关如何在 Vapor Web 框架中安装 SSL 的任何提示?我已经可以在 Apache、Nginx、Tomcat 等中正确安装 SSL。但在 Vapor 中从未成功,这似乎是 C 库问题,但我不知道它失败的真正原因,非常感谢您提供任何可能的帮助。

【问题讨论】:

  • 请去掉大图,加上相关文字。图片上的文字,无法索引。我不代表别人,但我不想花时间去尝试理解一堆图片。另外,清楚地说明错误是什么。我没有在你的照片中看到它。
  • 好的,谢谢你的建议,我已经删除了大图并添加了我得到的更多信息,我试着描述更多关于我得到的错误,虽然我不知道是什么这个问题发生了真正的错误。希望更新后的描述有所帮助。
  • 如果您可以在 Vapor 的 TLS 包上创建一个失败的测试用例:github.com/vapor/tls,这将帮助我们以最快的速度解决这个问题。要么是 LibreSSL 中的错误(可能但不太可能),要么是证书问题(如果它们与 Nginx 一起使用则不太可能),或者 Vapor 的 TLS 包缺少对 LibreSSL 的函数调用或错误地调用其中一个函数。

标签: ssl openssl vapor


【解决方案1】:

已在此处找到并修复该错误:https://github.com/vapor/tls/pull/27

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-15
    • 2016-08-30
    • 1970-01-01
    • 2016-07-22
    • 1970-01-01
    • 2015-08-20
    • 2017-03-05
    • 1970-01-01
    相关资源
    最近更新 更多