Open priyesh-shukla opened 3 years ago
Make sure you are using the latest versions of xmlseclibs and wse-php. If you are still getting an error you will need to paste your code as the only time you should see that is if you are trying to generate a session key using the above key type - which is incompatible.
Hi Please see my code below I am not able to sign soap request; `function finalSubmitITR(){ $login = 'ERIA101854'; $password = 'QWERTY@1'; $xmlFile = $_POST['itrxml']; $doc = new DOMDocument(); $doc->load($xmlFile); // Create a new Security object $objDSig = new XMLSecurityDSig(); // Use the c14n exclusive canonicalization $objDSig->setCanonicalMethod(XMLSecurityDSig::EXC_C14N); // Sign using SHA-256 $objDSig->addReference( $doc, XMLSecurityDSig::SHA256, array('http://www.w3.org/2000/09/xmldsig#enveloped-signature') );
// Create a new (private) Security key
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA256, array('type'=>'private'));
//If key has a passphrase, set it using
$objKey->passphrase = 'myitr1234';
// Load the private key
$objKey->loadKey('./app/controllers/myitr-privatekey.pem', TRUE);
// Sign the XML file
$objDSig->sign($objKey);
$tout = ('./app/controllers/myitr-privatekey.pem');
// Add the associated public key to the signature
$objDSig->add509Cert(file_get_contents($tout));
// Append the signature to the XML
$objDSig->appendSignature($doc->documentElement);
// Save the signed XML
/* $siteKey = new XMLSecurityKey(XMLSecurityKey::RSA_OAEP_MGF1P, array('type' => 'public')); $siteKey->loadKey('./app/controllers/EfilingDSC.cer', true, true);
$options = array("KeyInfo" => array("X509SubjectKeyIdentifier" => true));
$objWSSE->encryptSoapDoc($siteKey, $objKey, $options);
$retVal = parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
$doc = new DOMDocument();
$doc->loadXML($retVal);
$options = array("keys" => array("private" => array("key" => PRIVATE_KEY, "isFile" => true, "isCert" => false)));
$objWSSE->decryptSoapDoc($doc, $options);*/
$doc->save($xmlFile);
$zipFileName = str_replace('.xml','',$xmlFile);
$zipArchive = new ZipArchive();
if ($zipArchive->open($zipFileName.'.zip', (ZipArchive::CREATE | ZipArchive::OVERWRITE)) !== true)
die("Failed to create archive\n");
$zipArchive->addGlob($xmlFile);
if ($zipArchive->status != ZIPARCHIVE::ER_OK)
echo "Failed to write files to zip\n";
$zipArchive->close();
ini_set("soap.wsdl_cache_enabled", "1");
$wsdl = 'https://services.incometaxindiaefiling.gov.in/e-FilingSecWS/ditsecws/BulkItrService?wsdl';
$client = new SoapClient($wsdl, array(
"cache_wsdl"=>WSDL_CACHE_NONE,
"soap_version" => SOAP_1_1,
'trace' => 1,
'encoding' => 'UTF-8'
)
);
$client->__setSoapHeaders([new WsseAuthHeader($login, $password)]);
$requestId = "ERIA101854-".rand(100000,999999);
$codif = file_get_contents( $zipFileName.'.zip');
$xml_base64 = base64_encode($codif);
//$request = array('DitRequest' => array('_' => '', 'uniqueRequestId'=>$requestId, 'dataHandler' => $xml_base64)); $request = ' <soapenv:Envelope xmlns:soapenv="https://schemas.xmlsoap.org/soap/envelope/" xmlns:dit="https://incometaxindiaefiling.gov.in/ditsecws" xmlns:req="https://incometaxindiaefiling.gov.in/ditsecws/request">
Hi,
I have started the webservice integration for Income Tax bulk ITR but i am not able to encrypt the data by using public key of income tax getting following error.
Fatal error: Uncaught Exception: Unknown key size for type "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p"