question

KulerMaster-6431 avatar image
0 Votes"
KulerMaster-6431 asked cooldadtx commented

EBICS Initialization

Hi there,

I need to exchange the keys with our bank so we can start using their EBICS system.
I generated 3 different keys where one is for signature, second one for authentication and the third one for encryption.

 using (var provider = new RSACryptoServiceProvider(keySize))
 {                
     publicKey = provider.ToXmlString(false);
 }

Then I try to send the Modulus element from the exported XML for the signature key:

 <?xml version="1.0" encoding="utf-8"?>
 <ebicsUnsecuredRequest xmlns="urn:org:ebics:H005"
   xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="urn:org:ebics:H005 ebics_request_H005.xsd"
   Version="H005" Revision="1">
   <header authenticate="true">
     <static>
       <HostID>HOST-ID</HostID>
       <PartnerID>PARTNER-ID</PartnerID>
       <UserID>USER-ID</UserID>
       <OrderDetails>
         <AdminOrderType>INI</AdminOrderType>
         <OrderID>A001</OrderID>
         <OrderAttribute>DZNNN</OrderAttribute>
       </OrderDetails>
       <SecurityMedium>0200</SecurityMedium>
     </static>
     <mutable/>
   </header>
   <body>
     <DataTransfer>
       <OrderData>MODULUS-VALUE-HERE</OrderData>
     </DataTransfer>
   </body>
 </ebicsUnsecuredRequest>

Then I get an error message saying that XML data is not well formatted/formed. No further explanation unfortunately.
I wonder if I should encode the key or manipulate the key string in another way. However, like this it won't work :(

Is there anyone familiar with EBICS system that could help me with this? Would be greatly appreciated.

Thanks!

dotnet-csharpdotnet-aspnet-webpages
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

cooldadtx avatar image
1 Vote"
cooldadtx answered cooldadtx commented

The schema is available online. It depends on what version your bank is using. Running your XML against the schema indicates the following:

The 'urn:org:ebics:H005:PartnerID' element is invalid - The value 'PARTNER-ID' is invalid according to its datatype 'urn:org:ebics:H005:PartnerIDType' - The Pattern constraint failed.
The 'urn:org:ebics:H005:UserID' element is invalid - The value 'USER-ID' is invalid according to its datatype 'urn:org:ebics:H005:UserIDType' - The Pattern constraint failed.
The element 'OrderDetails' in namespace 'urn:org:ebics:H005' has invalid child element 'OrderID' in namespace 'urn:org:ebics:H005'.
The 'urn:org:ebics:H005:OrderData' element is invalid - The value 'MODULUS-VALUE-HERE' is invalid according to its datatype 'Base64Binary' - The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

Here's the test code (assuming you have your XML in a file and the XSD from the link given.

static void Main(string[] args)
{
    var sourceXml = @"C:\temp\test.xml";

    var doc = new XmlDocument();
    doc.Load(sourceXml);

    var schemas = Directory.EnumerateFiles(@"C:\temp", "*.xsd");
    foreach (var schema in schemas)
    {
        using (var stream = File.OpenRead(schema))
            doc.Schemas.Add(XmlSchema.Read(stream, null));
    };

    Console.WriteLine("Validating...");
    doc.Validate(( o, e ) => Console.WriteLine(e.Message));
    Console.WriteLine("Validated");
}

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hmm but those are the values that I've got received from the bank.
Anyway, your reply is marked as solution because you proved that there are some issues with the XML data. I will contact the support

Thank you

0 Votes 0 ·

Based upon the schema you cannot have spaces in the IDs so if you have spaces before and after your values inside the element then that would make it invalid.

Wrong:
```
<PartnerID>PARTNER-ID</PartnerID>
```

Right:
````
<PartnerID>MyID</PartnerID>
````

0 Votes 0 ·