- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 C++ 上完成了一些项目,我需要为 Windows XP 和更高版本编译它。
这是我的 RsaEncryptor
类的头文件(我认为在这里发布源代码无关紧要,因为我 100% 确定它工作正常,但如果需要的话我可以做到):
#ifndef RSAENCRYPTOR_H_
#define RSAENCRYPTOR_H_
#include <stdexcept>
#include <openssl/rsa.h>
#include <openssl/engine.h>
#include <openssl/pem.h>
// One of this paddings can be used
//#define PADDING RSA_PKCS1_OAEP_PADDING
#define PADDING RSA_PKCS1_PADDING
//#define PADDING RSA_NO_PADDING
class RsaEncryptor {
private:
RSA* publicKey;
RSA* privateKey;
public:
RsaEncryptor() {
publicKey = nullptr;
privateKey = nullptr;
}
~RsaEncryptor() {
if ( this->publicKey )
RSA_free( this->publicKey );
if ( this->privateKey )
RSA_free( this->privateKey );
}
size_t GetCipherBytesCount() {
return 172; //is default for 1024 bit key length
}
void SetPublicKeyFromString(const std::string& content);
void SetPrivateKeyFromString(const std::string& content);
std::string Encrypt(const std::string& plainData);
std::string Decrypt(const std::string& cipherData);
};
#endif /* RSAENCRYPTOR_H_ */
我使用最新版本的 Eclipse Neon
在 Windows 10 x64
机器上进行 C++ 开发。
我也读过this :
(...) you will need to configure with
no-async
when building OpenSSL 1.1.0 and above for Windows XP or Vista
然后我得到了 following 的指导说明。
我做了什么:
在 Windows 10 x64
下的 Virtual Box 中安装 Ubuntu 17.04 x64
。
从 Ubuntu
安装 mxe和所有要求(但无法用它编译,我决定使用 mingw32
)
通过 root@user-pc:/home/user# apt-get install gcc-mingw-w64-i686
安装 mingw32
在 /home/user/openssl-x32
中解压 OpenSSL 库
转到/home/user/openssl-x32
运行 ./Configure mingw --cross-compile-prefix=i686-w64-mingw32 --prefix=/home/user/builds/openssl-x32-static no-shared no-async
运行make
运行安装
从 /home/user/builds/openssl-x32-static/lib
复制 libssl.a
和 libcrypto.a
到主机 (Windows 10 x64
) 到文件夹 E:\MyProjects\my-app\libraries\
将 include
目录从 Ubuntu
复制到主机文件夹 E:\MyProjects\my-app\include
将 libraries
文件夹添加到链接器配置
将include
文件夹添加到编译器配置
然后,我构建了我的项目并得到了以下答案:
11:58:09 **** Rebuild of configuration Debug for project app **** Info: Configuration "Debug" uses tool-chain "MinGW GCC" that is unsupported on this system, attempting to build anyway. Info: Internal Builder is used for build g++ "-IC:\MyProjects\my-app\include" -O0 -g3 -Wall -c -std=c++11 -m32 -o RsaEncryptor.o "..\RsaEncryptor.cpp" g++ "-IC:\MyProjects\my-app\include" -O0 -g3 -Wall -c -std=c++11 -m32 -o main.o "..\main.cpp" In file included from ..\main.cpp:5:0: ..\FilesFinder.h: In member function 'void FilesFinder::FindRecursively(const string&, const FilesFilter&)': ..\FilesFinder.h:90:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] while (destinationContainer.GetElementsCount() >= MAX_ELEMENTS_COUNT) { ^ g++ "-IC:\MyProjects\my-app\include" -O0 -g3 -Wall -c -std=c++11 -m32 -o aes256.o "..\aes256.cpp" g++ "-LC:\MyProjects\my-app\libraries" -static-libgcc -static-libstdc++ -static -lpthread -m32 -o C:/MyProjects/my-app/bin/Debug/app RsaEncryptor.o aes256.o main.o -lssl -lcrypto -lgdi32 C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xaa): undefined reference to
_imp__getnameinfo@28'
_imp__ntohs@4' C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0x242): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xe0):
undefined reference togai_strerrorW'
_imp__freeaddrinfo@4' C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xb5d): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0x820):
undefined reference to_imp__getaddrinfo@16'
gai_strerrorW' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xd7): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_addr.o):b_addr.c:(.text+0xba2):
undefined reference to_imp__WSAStartup@8'
_imp__WSAGetLastError@0' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x2c7): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xe8):
undefined reference to_imp__WSAStartup@8'
_imp__WSAGetLastError@0' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x3b1): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x2d8):
undefined reference to_imp__ntohs@4'
_imp__getsockopt@20' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x423): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x40c):
undefined reference to_imp__WSAGetLastError@0'
_imp__gethostbyname@4' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x48b): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x43c):
undefined reference to_imp__WSAStartup@8'
_imp__WSAGetLastError@0' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x52c): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x4a2):
undefined reference to_imp__WSACleanup@0'
_imp__ioctlsocket@12' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x563): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x54d):
undefined reference to_imp__WSAGetLastError@0'
_imp__WSAStartup@8' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x6c8): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x6b7):
undefined reference to_imp__WSAGetLastError@0'
_imp__WSAGetLastError@0' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x9dc): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0x942):
undefined reference to_imp__setsockopt@20'
_imp__ioctlsocket@12' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xa32): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xa15):
undefined reference to_imp__WSAGetLastError@0'
_imp__getsockname@12' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xb22): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock.o):b_sock.c:(.text+0xaa6):
undefined reference to_imp__WSAGetLastError@0'
_imp__socket@12' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x4e): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x27):
undefined reference to_imp__WSAGetLastError@0'
_imp__setsockopt@20' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x15b): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x120):
undefined reference to_imp__connect@12'
_imp__setsockopt@20' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x206): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x1f5):
undefined reference to_imp__WSAGetLastError@0'
_imp__WSAGetLastError@0' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x2c6): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x265):
undefined reference to_imp__WSAGetLastError@0'
_imp__getsockopt@20' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x38f): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x377):
undefined reference to_imp__WSAGetLastError@0'
_imp__setsockopt@20' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x4b4): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x4a7):
undefined reference to_imp__WSAGetLastError@0'
_imp__bind@12' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x55f): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x53a):
undefined reference to_imp__listen@8'
_imp__setsockopt@20' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x5b6): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x5a5):
undefined reference to_imp__WSAGetLastError@0'
_imp__setsockopt@20' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x64b): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x63a):
undefined reference to_imp__WSAGetLastError@0'
_imp__WSAGetLastError@0' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x713): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x6b2):
undefined reference to_imp__WSAGetLastError@0'
_imp__accept@12' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x7e7): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x7a6):
undefined reference to_imp__WSAGetLastError@0'
_imp__closesocket@4' C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x86c): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(b_sock2.o):b_sock2.c:(.text+0x84b):
undefined reference to_imp__closesocket@4'
_imp__WSASetLastError@4' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x1d0): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x1b1):
undefined reference to_imp__send@16'
_imp__WSAGetLastError@0' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x272): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x20a):
undefined reference to_imp__WSASetLastError@4'
_imp__send@16' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x2ca): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x299):
undefined reference to_imp__WSAGetLastError@0'
_imp__WSASetLastError@4' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x360): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x33d):
undefined reference to_imp__recv@16'
_imp__WSAGetLastError@0' C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x457): undefined reference to
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):bss_sock.c:(.text+0x39a):
undefined reference to_imp__WSAGetLastError@0'
.rdata' c:/programs/mingw_w64_mingw32_gcc_stdthread_win32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld.exe: final link failed: Invalid operation collect2.exe: error: ld returned 1 exit status
c:/programs/mingw_w64_mingw32_gcc_stdthread_win32/bin/../lib/gcc/i686-w64-mingw32/4.8.1/../../../../i686-w64-mingw32/bin/ld.exe:
C:\MyProjects\my-app\libraries\libcrypto.a(bss_sock.o):
bad reloc address 0x24 in section11:58:21 Build Finished (took 11s.567ms)
我只需要将我完成的 C++ 项目与正确编译的(带有标记 no-async
)的 OpenSSL 库链接起来,让它在旧版本的 Windows 下工作。
我很乐意就此问题获得任何帮助。
最佳答案
错误日志中的大部分(如果不是全部) undefined symbol 都来自 Winsock。尝试使用 -lws2_32
链接。
关于c++ - 无法将 C++ 项目与 openssl 静态库链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44694954/
如果我使用open ssl命令 sudo openssl genrsa -out privkey.pem 2048 要生成rsa key ,它仅生成1个文件。这是私钥。我如何获得公钥。 最佳答案 回答
三个不同版本的 openssl 正在同时更新 openssl.org : 0.98, 1.0.0, 1.0.1?它们之间有什么区别,我该如何选择要使用的版本? 最佳答案 https://en.wiki
我有以下命令用于 OpenSSL 生成私钥和公钥: openssl genrsa –aes-128-cbc –out priv.pem –passout pass:[privateKeyPass] 2
我正在尝试使用对应的 gcc (arm-none-eabi-5_4-2016q2) 为 cortex m3 机器交叉编译 openssl。机器应该有能力做 TCP 请求,我们希望在一天结束时做 HTT
我正在尝试使用 openssl dsa 实现,但我对以下细节感到非常困惑: 命令 openssl dsa .... 的选项“-text”:输出中的十六进制数字,我是否正确地假设这些是字节,因此它们是按
我正在尝试制作一个假 CA 并用它签署一个证书以与 stunnel 一起使用(这似乎只是调用 OpenSSL 例程,因此您可能不需要了解该程序来提供帮助:)。然而,stunnel 一直拒绝我的证书,说
不幸的是,Perl 在尝试安装 OpenSSL 的手册页(例如 OpenSSL_1_0_1g)时不知何故遇到了错误。因为我不需要它们 - 我只想使用 OpenSSL 作为 C 库,我想我可以通过完全跳
OpenSSL 中的 BIO 对到底是什么?它的用途是什么?我已经检查过 OpenSSL 文档,但任何细节都很少。 最佳答案 OpenSSL 中的 BIO 类似于文件句柄。您可以使用一对它们来安全地相
openssl ca 和 openssl x509 命令有什么区别?我正在使用它来创建和签署我的 root-ca、intermed-ca 和客户端证书,但是 openssl ca 命令不会在证书上注册
如何(如果有的话)为 OpenSSL 定义一个单一的可信证书文件在 Windows(Win-7,OpenSSL 1.0.1c)上使用 SSL_CERT_FILE 环境变量? 各种研究促使我下载了 Mo
我有一个自签名证书,其中显示了列出的基本约束,但从中生成的签名请求不显示这些属性,例如 [v3_req]。我怎样才能让它可见?我正在使用 openssl 生成证书。 场景: 我使用以下方法创建自签名证
这个问题在这里已经有了答案: Check if a connection is TLSv1 vs SSLv3 (SSL_CIPHER_description/SSL_CIPHER_get_name)
是否有更简单的方法来确定在构建 openssl 期间指定的选项,例如当时是否定义了 OPENSSL_NO_SRTP? 我只能从以下方面获得有限的信息: openssl 版本 -a 命令。但是,如果我只
我们正在与 AWS Nitro 合作,仅提供 3 小时的证书。 我们正在寻找一种可以跳过验证中的过期部分并仍然确认证书链有效的方法。 最佳答案 根据 openssl-verify 文档
嗨,我如何在 Easyphp 中启用 openssl,因为我收到错误消息无法发送。Mailer 错误:缺少扩展:opensslTime:使用 phpmailer 时。谢谢 最佳答案 在您的 php.i
我正在尝试以编程方式读取 OpenSSL 警报消息,但无法找到执行此操作的方法。 OpenSSL API 提供如下功能: const char *SSL_alert_type_string(int v
我跑了openssl speed在我的 Ubuntu 计算机上。一些结果: Doing md4 for 3s on 16 size blocks: 9063888 md4's in 3.00s Doi
我编译了带有cryptodev支持(即硬件加速)的OpenSSL,但不幸的是默认引擎仍然是软件。 time openssl speed -evp aes-128-cbc -engine cryptod
我需要从 RedHat Linux 服务器连接到 Microsoft Dynamics CRM 服务器。地址是xxx.api.crm4.dynamics.com。服务器接受 TLSv1 但不接受 1.
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 上个月关闭。 Improve thi
我是一名优秀的程序员,十分优秀!