Search code examples
c++sslsoapcertificate-signing-request

CreatePKCS10CSR soap message in c++


I should give a signing request to a device with soap message. I included in my soap the following messages: http://www.onvif.org/ver10/advancedsecurity/wsdl/advancedsecurity.wsdl and I built my c++ project with VS2019 in Windows x64.

Now I'm trying to send a CreatePKCS10CSR with no success.

    #include "soapKeystoreBindingProxy.h"
        int CertificateRequest(const char* Country, const char* Province, const char* Locality, const char* Organization, const char* OrganizationalUnit, const char* CommonName, const char* KeyID, const char* SignatureAlgorithm, std::string* Response, int* maxLength)
        {
            deviceKeyStoreBindingProxy = new KeystoreBindingProxy();
        
            soap_register_plugin(deviceKeyStoreBindingProxy, http_da);
            deviceKeyStoreBindingProxy->userid = GetUser();
            deviceKeyStoreBindingProxy->passwd = GetPwd();
            
            //CreatePKCS10CSR
            _tas__CreatePKCS10CSR tas__CreatePKCS10CSR_tmp;
            _tas__CreatePKCS10CSRResponse tas__CreatePKCS10CSRResponse_tmp;
        
            tas__DistinguishedName* Subject_tmp;
            Subject_tmp = new tas__DistinguishedName();
            Subject_tmp->CommonName.push_back(CommonName);
            Subject_tmp->Country.push_back(Country);
            Subject_tmp->StateOrProvinceName.push_back(Province);
            Subject_tmp->Locality.push_back(Locality);
            Subject_tmp->Organization.push_back(Organization);
            Subject_tmp->OrganizationalUnit.push_back(OrganizationalUnit);
        
            tas__CreatePKCS10CSR_tmp.Subject = Subject_tmp;
        
            deviceKeyStoreBindingProxy->CreatePKCS10CSR(&tas__CreatePKCS10CSR_tmp, tas__CreatePKCS10CSRResponse_tmp);
            return 0;
        }

This is my tentative code but it doesn't work, I don't receive nothing in response. Could you give me an example how to handle the CreatePKCS10CSR? Any suggestion how to debug that code?


Solution

  • This code solve my question. In my previous code I forgot to declare the soap endpoint of remote device service. I also use a different authentication method.

    deviceKeyStoreBindingProxy = new KeystoreBindingProxy();
    
    
    soap_register_plugin(deviceKeyStoreBindingProxy, soap_wsse); //NOTE THIS LINE
    deviceKeyStoreBindingProxy->send_timeout = 3;
    deviceKeyStoreBindingProxy->recv_timeout = 5;
    deviceKeyStoreBindingProxy->connect_timeout = 5;
    
    deviceKeyStoreBindingProxy->userid = GetUser();
    deviceKeyStoreBindingProxy->passwd = GetPwd();
    
    deviceKeyStoreBindingProxy->soap_endpoint = GetSoapEndpointService(); //NOTE THIS LINE
    
    //CreatePKCS10CSR
    _tas__CreatePKCS10CSR tas__CreatePKCS10CSR_tmp;
    _tas__CreatePKCS10CSRResponse tas__CreatePKCS10CSRResponse_tmp;
    
    tas__DistinguishedName* Subject_tmp;
    Subject_tmp = new tas__DistinguishedName();
    Subject_tmp->CommonName.push_back(CommonName);
    Subject_tmp->Country.push_back(Country);
    Subject_tmp->StateOrProvinceName.push_back(Province);
    Subject_tmp->Locality.push_back(Locality);
    Subject_tmp->Organization.push_back(Organization);
    Subject_tmp->OrganizationalUnit.push_back(OrganizationalUnit);
    
    tas__CreatePKCS10CSR_tmp.Subject = Subject_tmp;
    
    
    AddUsernameTokenDigest(deviceKeyStoreBindingProxy, NULL, GetUser(), GetPwd(), deltaT);
    deviceKeyStoreBindingProxy->CreatePKCS10CSR(&tas__CreatePKCS10CSR_tmp, tas__CreatePKCS10CSRResponse_tmp);
    
    tas__CreatePKCS10CSRResponse_tmp = tas__CreatePKCS10CSRResponse_tmp;