我正在尝试与SSL进行SSL握手www1.filemail.com.我正在使用cURL cacert.pem,但我收到此错误:
Unacceptable certificate from 188.138.81.30: application verification failure
Run Code Online (Sandbox Code Playgroud)
与任何其他HTTPS网站进行握手有效 - 包括www2.filemail.com.www1并且www2应该配置相同 - 并且它们在所有浏览器中都能正常工作.他们也在这里测试很好(两个站点都发送了相同的证书和中间证书):
为什么我www1使用OpenSSL和cacert.pem文件会遇到这个问题?
www1和www2的证书设置必须有所不同.我已经使用无数的工具(openssl,ssllabs等)进行了测试,试图找出差异 - 但我总是得到两个站点完全相同的结果(运行我的代码时除外)
我在这里错过了什么?这些网站有什么区别?
(应该注意的是,我们使用的是RapidSSL提供的相对便宜的通配符证书 - 所以我猜它与中间证书或跨根证书有关 - 但是当使用上面提到的工具进行测试时,一切似乎都是有序的.)
码:
Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> pCert = new Poco::Net::ConsoleCertificateHandler(false);
Poco::Net::Context::Ptr pContext = new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "", "", "C:\\cacert.pem", Poco::Net::Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
Poco::Net::SSLManager::instance().initializeClient(0, pCert, pContext);
URI uri("https://www1.filemail.com");
Poco::Net::SecureStreamSocket ss(Poco::Net::SocketAddress(uri.getHost().c_str(), uri.getPort()));
ss.completeHandshake();
Run Code Online (Sandbox Code Playgroud) 所以我的问题实际上有几个部分:
使用Poco线程库:
我已经看过这里了:
提前致谢...
使用HTTPClientSession的常用示例代码如下所示:
Poco::Net::HTTPClientSession session(uri.getHost(), uri.getPort());
std::ostream& ostr = session.sendRequest(req);
// Receive the response.
Poco::Net::HTTPResponse res;
std::istream& rs = session.receiveResponse(res);
Run Code Online (Sandbox Code Playgroud)
问题是,如何从rs输入流中读取整个数据,同时确保所有操作都是非阻塞的,以便我可以随时取消它们?
我想使用一些跨平台的C++库来启动,停止和获取进程的标准输出.我发现并且我想使用C++ POCO库:这些好吗?
什么是最好的选择?我使用Boost并且他们有Boost Process,但不是官方发布和AFAIK的一部分它不会很快(发展在2008年停止).你能告诉我一下这个POCO lib或其他吗?
我试图了解如何在我的C++项目中使用非标准库.我有几个问题.
让我们说我想使用POCO库.所以我下载了它并使用make(静态构建)构建它.现在我有一堆.o文件和.h文件.在不同的目录中有一个Path.h文件和一个Path.o文件.
现在我想在我的代码中使用这个模块.所以我使用#include"Poco/Path.h"包含文件.我是否必须修改makefile并将Path.o添加到目标中?
使用标准库时会发生什么?那些仅在头文件中可用吗?我知道模板代码无法预编译.剩下的呢?
对于学校项目,我们必须通过网络发送大文件.我们必须使用Poco :: XML作为我们的数据.
我们的文件通过网络发送后,内存似乎没有释放.
以下是~9 Mb接收部分文件的示例:
valgrind --leak-check=full --show-reachable=yes -v ourExecutable parms 收益:
12,880,736 bytes in 37 blocks are definitely lost in loss record 101 of 101
at 0x4C2747E: operator new(unsigned long) (vg_replace_malloc.c:261)
by 0x5A3AC88: std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (in /usr/lib64/gcc/x86_64-pc-linux-gnu/4.4.4/libstdc++.so.6.0.13)
by 0x5A3BC4A: std::string::_Rep::_M_clone(std::allocator<char> const&, unsigned long) (in /usr/lib64/gcc/x86_64-pc-linux-gnu/4.4.4/libstdc++.so.6.0.13)
by 0x5A3C1BB: std::string::reserve(unsigned long) (in /usr/lib64/gcc/x86_64-pc-linux-gnu/4.4.4/libstdc++.so.6.0.13)
by 0x5A3C68E: std::string::append(std::string const&) (in /usr/lib64/gcc/x86_64-pc-linux-gnu/4.4.4/libstdc++.so.6.0.13)
by 0x5202359: Poco::XML::Element::innerText() const (in /home/tomwij/IGS/trunk/Project/external/lib/libPocoXML.so.8)
by 0x4145BF: NodeProtocol::getChildNodeStrValue(Poco::XML::Element*, std::string) (NodeProtocol.cpp:82)
by 0x41544F: NodeProtocol::deserialize(std::string const&) …Run Code Online (Sandbox Code Playgroud) 我想在Mac OS上构建32位Poco库(因为我有其他固定的32位依赖项).默认情况下,Poco仅为x86_64目标构建.
我尝试像这样构建Poco(根据Poco构建说明):
POCO_TARGET_OSARCH=i386 make
Run Code Online (Sandbox Code Playgroud)
但是,它仍然只为x86_64构建.有任何想法吗?
============================================
好吧,事实证明答案是这样的(如果有其他人遇到这个):
在运行configure和make之前,需要导出这两个变量:
POCO_TARGET_OSARCH="i386"
ARCHFLAGS="-arch i386"
Run Code Online (Sandbox Code Playgroud) 我想使用HTTP PUT请求将一些数据从C++应用程序发送到服务器.我在我的应用程序中使用poco库进行联网.
我正在使用此代码段:
HTTPClientSession session(_uri.getHost(), _uri.getPort());
HTTPRequest req(HTTPRequest::HTTP_PUT, path, HTTPMessage::HTTP_1_1);
Run Code Online (Sandbox Code Playgroud)
发送请求时,我在哪里设置内容(文件)流?有人能告诉我一个使用这个库的例子吗?
我正在尝试使用Poco Libraries(版本poco-1.4.6p1-all)在C++中编写客户端应用程序,并在Visual Studio 2010中编译,它将HTTPS请求发送到具有自写证书的服务器.我有一个错误,因为证书无法识别:
First-chance exception at 0x76e8c41f in httprequest.exe: Microsoft C++ exception: Poco::Net::SSLException at memory location 0x0044ed38..
我已经尝试更改库中编写的验证函数(在X509Certificate.h中),以便它们始终返回true并重建库.同样的错误.
这是代码:
try{
const Poco::URI uri("https://www.theServer.com");
Poco::Net::Context::Ptr context =
new Poco::Net::Context(Poco::Net::Context::CLIENT_USE, "",
"","",Poco::Net::Context::VERIFY_RELAXED,
9, true, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
Poco::SharedPtr<Poco::Net::InvalidCertificateHandler> pAcceptCertHandler = new Poco::Net::AcceptCertificateHandler(true);
Poco::Net::SSLManager::instance().initializeClient(NULL, pAcceptCertHandler, context);
Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort(), context );
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, "" );
req.setContentType("application/x-javascript; charset=utf-8\r\n");
req.setKeepAlive(true);
Poco::Net::HTTPBasicCredentials cred("lala@lala.lala", "lala");
cred.authenticate(req);
session.sendRequest(req);
Poco::Net::HTTPResponse res;
std::istream& rs = session.receiveResponse(res);
std::string resp;
std::vector<Poco::Net::HTTPCookie> cookies;
res.getCookies( cookies );
res.write(std::cout);
}
catch( const Poco::Net::SSLException& e )
{ …Run Code Online (Sandbox Code Playgroud) 我有一个嵌套的JSON对象.我正在尝试在函数中构建它并将内部对象添加到原始对象中,但我无法提取结果.
void build_object (Poco::JSON::Object * const result)
{
/* Construct some int/bool/string fields here */
Poco::JSON::Object inner;
inner.set("some_number", 5);
inner.set("some_string", "xyz");
/* This is where it breaks down */
std::string key = "new_object";
result->set("new_object", inner);
/* Then some debugging and testing */
// The new object is printed inside the first -> seems like it's working
result->stringify(std::cout);
printf("result has(key): %i\n", result->has(key)); // true
printf("isObject: %i\n", result->isObject(key)); // false - huh?
printf("isNull: %i\n", result->isNull(key)); // false
printf("isArray: %i\n", result->isArray(key)); // false …Run Code Online (Sandbox Code Playgroud) poco-libraries ×10
c++ ×8
http ×2
ssl ×2
32bit-64bit ×1
asynchronous ×1
compilation ×1
https ×1
json ×1
linker ×1
makefile ×1
networking ×1
nonblocking ×1
openssl ×1
pki ×1
stl ×1
stream ×1
string ×1
valgrind ×1