在Windows 7中使用OpenSSL的问题

时间:2011-06-29 21:20:46

标签: windows-7 openssl

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

  • 在MS-DOS命令提示符下,我尝试使用

    创建根CA.
    openssl x509 -req -in rootreq.pem -sha1  -extensions v3_ca 
      -signkey rootkey.pem -out rootcert.pem
    

但是出现了以下错误unable to write random state。 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;
}

3 个答案:

答案 0 :(得分:2)

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

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

有一些说明和示例应用程序

答案 1 :(得分:1)

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

答案 2 :(得分:0)

当您单击命令提示符时,右键单击并单击以管理员身份运行,以清除您的问题