小编acp*_*der的帖子

关于在没有WndProc的情况下运行win32事件循环的不同方法的想法?

在搞乱多线程,回调,win32 api功能以及其他麻烦的问题时,我收到了一个想法事件.(呵呵呵)

如果,而不是(设计一个类时或静态)回调函数定义一个全球性的,而不是我指派DefWindowProclpfnWndProc注册窗口类的时候,然后运行在一个单独的线程整个事件循环?

这样我就不必在类中实现回调this时解决问题, 并且主线程的执行继续进行,让你从那个被遗忘的循环中解放出来,允许你做任何事情,甚至打开另一个窗口(耶!)

"正常"方式:

LRESULT CALLBACK WndProc(...)
{
    ... // process event information
    return DefWindowProc(...);
}

int CALLBACK WinMain(...)
{
    ... // initialize whatever needs initializing :)
    WNDCLASSEX wc;
    ...
    wc.lpfnWndProc = WndProc;
    ... // register the class, create the window, etc...

   MSG msg;
   while(GetMessage(&msg, 0, 0, 0) != 0)
   {
        ... // TranslateMessage(&msg) if you want/need it
        DispatchMessage(&msg); // dispatches the message to WndProc
   }

   return static_cast<int>(msg.wParam);
}
Run Code Online (Sandbox Code Playgroud)

我新发现的令人敬畏的方式:

DWORD …
Run Code Online (Sandbox Code Playgroud)

c++ windows winapi multithreading event-loop

5
推荐指数
2
解决办法
4175
查看次数

如何在根 CA 下生成服务器和客户端证书

因此,我一直在尝试在 python 客户端和 python 服务器之间建立 SSL 连接,其中两者都有单独的证书来相互验证,并且两个证书都由一个 CA(它也恰好是根 CA)签名. 这应该使它们对彼此都有效,对吗?

到目前为止,我的方法是创建一个 bash 脚本来完成这一切:

  1. 它为根 CA 生成私钥
  2. 它使用根 CA 私钥生成根 CA 证书
  3. 它为服务器生成私钥
  4. 它为服务器生成 CSR
  5. 它使用服务器 CSR 和根 CA 证书生成服务器证书
  6. 它为客户端生成私钥
  7. 它为客户端生成 CSR
  8. 它使用客户端 CSR 和根 CA 证书生成客户端证书
#!/bin/bash

BOLD=$(tput bold)
CLEAR=$(tput sgr0)

echo -e "${BOLD}Generating RSA AES-256 Private Key for Root Certificate Authority${CLEAR}"
openssl genrsa -aes256 -out Root.CA.example.llc.key 4096

echo -e "${BOLD}Generating Certificate for Root Certificate Authority${CLEAR}"
openssl req -x509 -new -nodes -key Root.CA.example.llc.key -sha256 -days 1825 -out Root.CA.example.llc.pem

echo …
Run Code Online (Sandbox Code Playgroud)

python bash ssl-certificate x509certificate

5
推荐指数
1
解决办法
7593
查看次数