XML Signing

Full reference for XMLDSig signing and verification — enveloped, enveloping, and detached signatures for GST, e-invoice, and government XML.

All features supported

Every XML signing capability listed below is implemented and working on Mobile App and Desktop Software. XMLDSig follows W3C standards with CCA India certificate chains.

Overview

SecureSign signs XML documents using XML Digital Signature (XMLDSig). Supports enveloped signatures (signature inside the document), enveloping signatures (document inside signature), and detached signatures (signature separate from document).

  • Primary use cases: GST returns, e-invoice (IRN), MCA XML filings, custom government XML schemas.
  • Default hash algorithm: SHA256.
  • Canonicalization: Exclusive C14N (http://www.w3.org/2001/10/xml-exc-c14n#).

Platform Support

FeatureMobile AppDesktop SoftwareREST API
XMLDSig SignDeep linkDeep linkPOST /sign/xml
XMLDSig VerifySupportedPOST /verify/xmlPOST /verify/xml
Enveloped SignatureDefaultsignatureType: envelopedsignatureType: enveloped
Enveloping SignatureSupportedsignatureType: envelopingsignatureType: enveloping
Detached XML SignatureSupportedsignatureType: detachedsignatureType: detached
XML ValidationVerify endpointPOST /verify/xmlPOST /verify/xml
Certificate ExtractionVerify responseVerify responseSigner cert in response

Request Fields

FieldTypeRequiredDescription
xmlBase64stringYes*Base64-encoded XML (*or xmlContent as UTF-8 string)
xmlContentstringYes*Raw XML string (alternative to base64)
signatureTypestringNoenveloped (default), enveloping, or detached
hashAlgostringNoSHA256 (default), SHA384, SHA512
signatureIdstringNoXMLDSig Id attribute (e.g. SigFrst for GST)
referenceUristringNoReference URI for enveloped signing (e.g. empty string for whole document)
certSerialstringNoPre-select certificate
callbackUrlstringREST onlyServer callback URL

Signature Types

signatureTypeStructureBest for
enveloped<ds:Signature> inside the XML documentGST, e-invoice, MCA filings
envelopingDocument embedded inside <ds:Object>Standalone signature containers
detachedSignature returned separately from documentExternal signature storage

Examples

Enveloped — GST / e-invoice

const params = new URLSearchParams({
  requestId: crypto.randomUUID(),
  hashBase64: sha256Base64,
  hashAlgo: 'SHA256',
  documentType: 'xml',
  callbackUrl: 'https://portal.example.gov.in/sign/callback',
  apiKey: 'ss_live_abc123xyz'
});
window.location.href = `securesign://sign?${params}`;

Detached signature

securesign://sign?documentType=xml&amp;...
{
  "xmlBase64": "PD94bWwgdmVyc2lvbj0iMS4wIj8+...",
  "signatureType": "detached",
  "hashAlgo": "SHA256"
}

Response

Enveloped

{"success":true,"signedXml":"<Invoice>...<ds:Signature Id=\"SigFrst\">...</ds:Signature></Invoice>","digestValid":true,"signatureId":"SigFrst"}

Detached

{"success":true,"signatureXml":"<ds:Signature>...</ds:Signature>","originalXmlDigest":"a1b2c3..."}

Errors

CodeCauseResolution
SS_XML_INVALIDMalformed XML inputValidate XML well-formedness before signing
SS_XML_SIGNATURE_EXISTSDocument already contains signature with same IdUse unique signatureId
SS_SIGNATURE_TYPE_INVALIDUnknown signatureTypeUse enveloped, enveloping, or detached
SS_CANONICALIZATION_FAILEDC14N transform errorCheck XML namespaces and encoding

See also Signing API — POST /sign/xml and Verification Engine.