在 Windows 7 中使用 OpenSSL 的问题

发布于 2024-11-17 13:40:44 字数 2201 浏览 4 评论 0原文

我注意到在 Windows XP Professional 和 Windows 7 Professional 上安装 OpenSSL 之间存在一些问题。对于这两个操作系统,我从 Shining Light Productions 网站下载了 Win32 OpenSSL v1.0.0dVisual C++ 2008 Redistributables 二进制文件。两台机器上都安装没有问题。但是,在 Windows 7 计算机上,我使用 OpenSSL exe 和 API 遇到了以下问题:

  • 从 MS-DOS 命令提示符中,我尝试使用以下命令创建根 CA

    openssl x509 -req -in rootreq.pem -sha1 -extensions v3_ca 
      -signkey rootkey.pem -out rootcert.pem
    

但出现以下错误无法写入随机状态。 Windows XP 运行良好。

  • 我使用 OpenSSL API 编译了一个简单的 SSL Web 服务器,但是当我尝试使用
<前><代码>openssl s_client -connect 127.0.0.1:16001

我得到以下响应

Loading 'screen' into random state - done
connect: No such file or directory
connect:errno=0

Windows XP 再次返回了更好的响应。如果您查看我附加的代码,似乎第二个 BIO_do_accept 永远不会被调用。

有谁知道可能是什么问题?在 Windows 7 上安装时是否需要执行额外的步骤?

仅供参考 - 我也尝试在 Windows 7 上安装 64 位二进制文​​件,但得到了相同的结果。我确实需要在我的 Windows 7 机器上安装并运行它,因此非常感谢您的帮助。

///////////////////  Code ///////////////////////////////////

// Simple OpenSSL Webserver
// Compiler : MSVS 2010 Professional
// Language: C / C++

int main(int argc, char *argv[])
{
    BIO         *acc, *client;
    SSL         *ssl;
    SSL_CTX     *ctx;
    THREAD_TYPE tid;

    init_OpenSSL(  );
    seed_prng(  );

    ctx = setup_server_ctx(  );

    acc = BIO_new_accept(PORT);

    printf ("BIO_new_accept\n");

    if (!acc)
        int_error("Error creating server socket");

    if (BIO_do_accept(acc) <= 0)
        int_error("Error binding server socket");

    printf ("BIO_do_accept\n");

    for (;;)
    {
        if (BIO_do_accept(acc) <= 0)
            int_error("Error accepting connection");

        printf ("BIO_do_accept2\n");

        client = BIO_pop(acc);

        printf ("BIO_pop\n");

        if (!(ssl = SSL_new(ctx)))
            int_error("Error creating SSL context");

        printf ("SSL_new\n");

        SSL_set_bio(ssl, client, client);

        printf ("SSL_set_bio\n");

        THREAD_CREATE(tid, (void *)server_thread, ssl);
    }

    SSL_CTX_free(ctx);
    BIO_free(acc);
    return 0;
}

I noticed some problems between installing OpenSSL on Windows XP Professional and Windows 7 Professional. For both OSs, I downloaded the Win32 OpenSSL v1.0.0d and Visual C++ 2008 Redistributables binaries from the Shining Light Productions website. Both installed with no problems on both machines. However, on the Windows 7 machine, I encountered the following problems using the OpenSSL exe and API:

  • From the MS-DOS command prompt, I tried to create a root CA with

    openssl x509 -req -in rootreq.pem -sha1  -extensions v3_ca 
      -signkey rootkey.pem -out rootcert.pem
    

but was given the following error unable to write random state. Windows XP worked fine.

  • I compiled a simple SSL web server using the OpenSSL API, but when I try to connect using
openssl s_client -connect 127.0.0.1:16001

I get the following response

Loading 'screen' into random state - done
connect: No such file or directory
connect:errno=0

Once again, Windows XP returned a better response. If you look at my attached code, it appears that the second BIO_do_accept never gets called.

Does anyone know what the problem may be ? Are there extra steps that I need to take when installing on Windows 7?

FYI - I also tried installing the 64 bit binaries on Windows 7 as well, but I got the same results. I really need to get this up and running on my Windows 7 machine, so any help is appreciated.

///////////////////  Code ///////////////////////////////////

// Simple OpenSSL Webserver
// Compiler : MSVS 2010 Professional
// Language: C / C++

int main(int argc, char *argv[])
{
    BIO         *acc, *client;
    SSL         *ssl;
    SSL_CTX     *ctx;
    THREAD_TYPE tid;

    init_OpenSSL(  );
    seed_prng(  );

    ctx = setup_server_ctx(  );

    acc = BIO_new_accept(PORT);

    printf ("BIO_new_accept\n");

    if (!acc)
        int_error("Error creating server socket");

    if (BIO_do_accept(acc) <= 0)
        int_error("Error binding server socket");

    printf ("BIO_do_accept\n");

    for (;;)
    {
        if (BIO_do_accept(acc) <= 0)
            int_error("Error accepting connection");

        printf ("BIO_do_accept2\n");

        client = BIO_pop(acc);

        printf ("BIO_pop\n");

        if (!(ssl = SSL_new(ctx)))
            int_error("Error creating SSL context");

        printf ("SSL_new\n");

        SSL_set_bio(ssl, client, client);

        printf ("SSL_set_bio\n");

        THREAD_CREATE(tid, (void *)server_thread, ssl);
    }

    SSL_CTX_free(ctx);
    BIO_free(acc);
    return 0;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

℡Ms空城旧梦 2024-11-24 13:40:44

我成功地使用 MinGW-w64 平台构建了我的 OpenSSL 应用程序(适用于 x86 和 x64 Windows),并且我在使用 Shining Light 二进制文件时也遇到了一些问题。

设置非常简单,http://www.blogcompiler.com/2011/12/21/openssl-for-windows/

I have success using the MinGW-w64 platform to build my OpenSSL applications (both for x86 and x64 Windows), and I also had some issues with the Shining Light binaries.

It is quite easy to set up, there are some instructions and a sample application at http://www.blogcompiler.com/2011/12/21/openssl-for-windows/

薯片软お妹 2024-11-24 13:40:44

感谢您的回答。我发现最好的方法是自己编译所有内容。我在以下站点找到了一个很好的教程 - http://www.askyb.com/windows/compiling-and-installing-openssl-for-32-bit-windows/

Thanks for the answer. I discovered that the best way was to compile everything myself. I found a good tutorial at the following site - http://www.askyb.com/windows/compiling-and-installing-openssl-for-32-bit-windows/

树深时见影 2024-11-24 13:40:44

当您单击命令提示符时,右键单击并单击以管理员身份运行,这应该可以解决您的问题

when you click on command prompt right click and click run as administrator that should clear up your issue

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文