Submitting files for signing

Use requestSigning to submit signing sets for signing.

Java
//add your client certificate
System.setProperty("javax.net.ssl.keyStoreType", "PKCS12");
System.setProperty("javax.net.ssl.keyStore", "C:\\\\Program Files\\\\Java\\\\jdk1.8.0_25\\\\bin\\\\sas_keystore.p12");
System.setProperty("javax.net.ssl.keyStorePassword", "yourPassword");

//specify your partner code, username, and password
AuthToken authToken = new AuthToken();
authToken.setPartnerCode("partner code");
authToken.setUserName("user name");
authToken.setPassword("password");

RequestSigningRequestType signingRequest = 
		new RequestSigningRequestType();
signingRequest.setAuthToken(authToken);
signingRequest.setPublisherID(4551181);
signingRequest.setApplication("files in base64-encoded zip format");
signingRequest.setApplicationName("applicationName1");
signingRequest.setApplicationVersion("1.3");
signingRequest.setCommaDelimitedFileNames("myfile.txt");
//signingRequest.setSigningAttributes(null);
//signingRequest.setSigningCertificateOptions(null);
//signingRequest.setSigningProfileName("ss");
signingRequest.setSigningServiceName("Microsoft Signing");

RequestSigningResponseType response;
try {
    SigningProxy request = new SigningProxy();
    response = request.requestSigning(signingRequest);
    
    //get the result code
    System.out.println("Result code: \\t" + response.getResult().getResultCode());
    
    //if the request is successful with or without warnings
    if (response.getResult().getResultCode() >= 0) {
        try {
            //list errors, if present
            Error[] error = response.getResult().getErrors();
            for (Error err : error) {
                if (!err.getErrorMessage().isEmpty()) {
                    System.err.println("Warning: " + err.getErrorMessage() + " Field: " + err.getErrorField());
                }
            }
        }
        catch (Exception e) {}
        
        //Print success message, other details
        System.out.println("Success!");
        System.out.println("Status: " +  response.getSigningSetStatus());
        System.out.println("Signature: " +  response.getSignature());
        System.out.println("Signature Set ID: " +  
          response.getSigningSetID());
        String[] certs = response.getCertificateInfo().getSigningCertificates();
    } else {
        //if the request failed, list any errors
        try {
            //list errors, if present
            Error[] error = response.getResult().getErrors();
            for (Error err : error) {
                if (!err.getErrorMessage().isEmpty()) {
                    System.err.println("Warning: " + err.getErrorMessage() + " Field: " + err.getErrorField());
                }
            }
        }
        catch (Exception e) {
            System.out.println("Error while reading request details");
        }
    }
}
catch (Exception e) {}
C#
//create the service object
SigningService signingService = new SigningService();

//add client cert for two-factor-authentication
string clientCertPath = "C:\\\\Users\\\\Administrator\\\\Desktop\\\\sas_pfx.pfx";
string clientCertPassword = "yourPassword";
X509Certificate2 clientCert = new X509Certificate2(clientCertPath, clientCertPassword);
signingService.ClientCertificates.Add(clientCert);

//add your username, password, and partnercode
AuthToken authToken = new AuthToken();
authToken.partnerCode = "partner code";
authToken.userName = "username";
authToken.password = "password";
RequestSigningRequestType signingRequest = new RequestSigningRequestType();
signingRequest.authToken = authToken;
signingRequest.publisherID = 123456789;

//file to be signed as base-64 encoded string converted to byte[]
signingRequest.application = Convert.FromBase64String("base64 encoded file");
signingRequest.applicationName = "applicationName1";
signingRequest.applicationVersion = "2.5";
signingRequest.commaDelimitedFileNames = "sample.exe";
//signingRequest.signingAttributes = null;
SigningCertificateOptionsType signingCertificateOptions = 
  new SigningCertificateOptionsType();
signingCertificateOptions.signingAction = "GENERATE_NEW_CERT";
//Give a new name each time you generate a new cert
signingCertificateOptions.certificateFriendlyName = "newcert10";
signingRequest.signingCertificateOptions = signingCertificateOptions;
//signingRequest.signingProfileName = "ss";
signingRequest.signingServiceName = "signing_service_name";

RequestSigningResponseType response;
try
{
    response = signingService.requestSigning(signingRequest);

    Console.WriteLine("Result code: " + response.result.resultCode);

    if (response.result.resultCode >= 0)
    {
        try
        {
            Error[] errors = response.result.errors;
            foreach (Error error in errors)
            {
                if (error.errorMessage.Length > 0)
                {
                    Console.WriteLine("Warning: " + error.errorMessage + " Field: " + error.errorField);
                }
            }
        }
        catch (Exception e) { }

        //Print success and signing details
        Console.WriteLine("Success!");
        Console.WriteLine("Status: " + response.signingSetStatus);
        Console.WriteLine("Signature: " + response.signature);
        Console.WriteLine("Signature Set ID: " + response.signingSetID);
        String[] certs = response.certificateInfo.signingCertificates;
    }
    else
    {
        try
        {
            //list errors, if present
            Error[] errors = response.result.errors;
            foreach (Error error in errors)
            {
                if (error.errorMessage.Length > 0)
                {
                    Console.WriteLine("Warning: " + error.errorMessage + " Field: " + error.errorField);
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Error while reading request details: " + e.InnerException.Message);
        }
    }
}
catch (Exception e) { }

We use cookies to ensure that we give you the best experience on our website. By using this site, you agree to the Terms of Service.