I have a web application in asp.net, which consumes a webservice in delphi and that it uses a DLL created in C # to perform signatures.
With the web application installed on IIS, it displays an error. When running webservice within IIS using SOAPUI it also displays error. When testing the webservice out of IIS using the delphi + SOAPUI process works. All tests were performed with NET 4.5.
All scenarios with errors occur in the ComputeSignature () method. Below the reported error.
System.ArgumentException: Caracteres inválidos no caminho.
em System.Security.Permissions.FileIOPermission.CheckIllegalCharacters(String[] str, Boolean onlyCheckExtras)
em System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
em System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
em System.AppDomainSetup.VerifyDir(String dir, Boolean normalize)
em System.AppDomainSetup.get_ConfigurationFile()
em System.Configuration.ClientConfigPaths..ctor(String exePath, Boolean includeUserConfig)
em System.Configuration.ClientConfigPaths.GetPaths(String exePath, Boolean includeUserConfig)
em System.Configuration.ClientConfigurationHost.GetStreamName(String configPath)
em System.Configuration.ClientConfigurationHost.get_IsAppConfigHttp()
em System.Configuration.ClientConfigurationSystem..ctor()
em System.Configuration.ConfigurationManager.EnsureConfigurationSystem()
In the DLL when switching from the .NET version to the 2.0 signing method works normally using within IIS.
I would like to know the reason for working in 2.0 and if there is any configuration that should be done in the DLL or IIS to work in version 4.5.
Here is the subscription code:
private XmlElement GerarAssinatura(bool IsSalvador, XmlDocument doc, XmlNode childNodes)
{
XmlElement retorno = null;
try
{
Reference reference = new Reference();
reference.Uri = "";
XmlElement childElemen = (XmlElement)childNodes;
if (childElemen.GetAttributeNode("Id") != null)
{
reference.Uri = "#" + childElemen.GetAttributeNode("Id").Value;
}
else if (childElemen.GetAttributeNode("id") != null)
{
reference.Uri = "#" + childElemen.GetAttributeNode("id").Value;
}
RSACryptoServiceProvider privateKeyProvider = (RSACryptoServiceProvider)certificado.PrivateKey;
SignedXml signedXml = new SignedXml(doc);
signedXml.SigningKey = privateKeyProvider;
XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();
reference.AddTransform(env);
if (!IsSalvador)
{
XmlDsigC14NTransform c14 = new XmlDsigC14NTransform();
reference.AddTransform(c14);
}
signedXml.AddReference(reference);
KeyInfo keyInfo = new KeyInfo();
KeyInfoX509Data x509Data = new KeyInfoX509Data(certificado);
if (IsSalvador)
{
KeyInfoClause rsaKeyVal = new RSAKeyValue((RSA)privateKeyProvider);
keyInfo.AddClause(rsaKeyVal);
x509Data.AddSubjectName(certificado.SubjectName.Name.ToString());
}
keyInfo.AddClause(x509Data);
signedXml.KeyInfo = keyInfo;
signedXml.ComputeSignature();
retorno = signedXml.GetXml();
}
catch (Exception erro)
{
AddMensagem("Ocorreu erro ao assinar. " + erro.InnerException.ToString());
}
return retorno;
}