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生成的证书不起作用?有人有证书我可以试试吗?