我想在C ++中使用带有gsoap的PayPal api。我的示例是在Linux上工作,但在Windows中,我来自于paypalProxy.GetBalance' "无法获得本地发行人证书"。
我已经知道,这是一个问题,openssl不知道可信任的CA. 当我发出:
openssl s_client -connect api-3t.sandbox.paypal.com:443 -showcerts | egrep -wi "G5|return"
在Linux中,我得到'验证返回代码:0(ok)'。在Windows上,我无法获得本地颁发者证书'。
添加选项' -CAfile。\ cabundle.crt'在Windows中,我还得到“验证返回代码:0(ok)'”,其中cabundle.crt是mozilla证书包feom here。
所以我想知道,我必须告诉openssl crt文件的位置与gsoap(甚至更好,系统范围,因为问题似乎不在代码中)
int main(int argc, char* argv[])
{
std::string strSignature;
PayPalAPISoapBindingProxy paypalProxy("https://api-3t.sandbox.paypal.com/2.0/");
struct soap *soap = soap_new(); // create a new context
soap_init(soap);
paypalProxy.header = new SOAP_ENV__Header;
paypalProxy.header->ns1__RequesterCredentials = new ns3__CustomSecurityHeaderType;
paypalProxy.header->ns1__RequesterCredentials->eBayAuthToken = NULL;
paypalProxy.header->ns1__RequesterCredentials->Credentials = new ns3__UserIdPasswordType;
paypalProxy.header->ns1__RequesterCredentials->Credentials->AppId = NULL;
paypalProxy.header->ns1__RequesterCredentials->Credentials->DevId = NULL;
paypalProxy.header->ns1__RequesterCredentials->Credentials->AuthCert = NULL;
paypalProxy.header->ns1__RequesterCredentials->Credentials->Username = soap_strdup(soap, "XXXXXX");
paypalProxy.header->ns1__RequesterCredentials->Credentials->Password = soap_strdup(soap, "XXXXXX");
strSignature = soap_strdup(soap, "XXXXXX"); // Sandbox env
paypalProxy.header->ns1__RequesterCredentials->Credentials->Signature = &strSignature;
_ns1__GetBalanceReq ns1__GetBalanceReq;
ns1__GetBalanceResponseType ns1__GetBalanceResponse;
ns1__GetBalanceReq.GetBalanceRequest = new ns1__GetBalanceRequestType;
ns1__GetBalanceReq.GetBalanceRequest->DetailLevel.push_back(ns3__DetailLevelCodeType__ReturnAll);
soap_ssl_init();
if (soap_ssl_client_context(soap, SOAP_SSL_DEFAULT, NULL, NULL, "cacert.crt", NULL, NULL))
{
soap_print_fault(soap, stderr);
exit(1);
}
char buf[1024];
int res = paypalProxy.GetBalance(&ns1__GetBalanceReq, ns1__GetBalanceResponse);
if (res != SOAP_OK)
{
soap_sprint_fault(soap, buf, 1024);
}
else
{
std::ostringstream oss;
oss << ns1__GetBalanceResponse.Balance << std::endl;
std::cout << oss.str() << std::endl;
oss << ns1__GetBalanceResponse.BalanceTimeStamp;
std::cout << oss.str() << std::endl;
//std::cout << ns1__GetBalanceResponse.BalanceHoldings. ->soap_serialize << std::endl;
//std::cout << ns1__GetBalanceResponse.BalanceTimeStamp soap_serialize << std::endl;
}