安全服务器不工作

时间:2012-05-14 03:01:59

标签: c++ api networking ssl liblacewing

Lacewing图书馆应支持托管安全服务器。

它表示如果证书正确加载,它应该是安全的。但是,我正在托管它并且它说证书已成功加载,但是当我从客户端向服务器发送消息时,我没有收到它。如果没有加载证书,我会这样做。

#include <string>
#include <iostream>  
#define  LacewingFunction
#include "Lacewing.h"

void onReceive (Lacewing::Server &Server, Lacewing::Server::Client &Client,
                char * Data, int Size) {
                    /* callback body */
                    std::cout << Data << "\n";
}

void onConnect (Lacewing::Server &Server, Lacewing::Server::Client &Client)
{
    std::cout << "Connected!" << "\n";
    Client.Send("TestingS");
}



void onReceiveC (Lacewing::Client &Client, char * Data, int Size)
{
    std::cout << Data << "\n";
    Client.Send("TesingC");
}


int main(int argc, char* argv[])  
{  
    std::string s;
    std::cin >> s;
    if(s == "server")
    {
        Lacewing::EventPump pump;
        Lacewing::Server* server = new Lacewing::Server(pump);
        server->LoadSystemCertificate("MY","localhost");
        std::cout << server->CertificateLoaded();
        server->onReceive(onReceive);
        server->onConnect(onConnect);
        server->Host(1234);
        std::cout << server->CertificateLoaded();
        pump.StartEventLoop();
    }
    else
    {
        Lacewing::EventPump pump;
        Lacewing::Client* server = new Lacewing::Client(pump);
        server->onReceive(onReceiveC);
        server->Connect("192.168.2.12",1234);
        pump.StartEventLoop();
    }

    return 0;  
}  

证书表明它已加载。

这是api文档。 http://lacewing-project.org/docs/server/LoadSystemCertificate.html

由于

也许makecert生成的证书不起作用?有没有人有我可以尝试的证书?

1 个答案:

答案 0 :(得分:1)

我正在尝试同样的事情。

bSecure = WebServer.LoadSystemCertificate("My", "localhost","localmachine");
bSecure = WebServer.CertificateLoaded();

两者都是,所以应加载证书。

请看这里:how to make a certificate

这在IE9中工作正常,端口设置为5040。 https://localhost:5040/ 它在Firefox或Chrome中不起作用,但这与加载“证书颁发机构”证书有关。