Skip to content

Support X509Certificate in INI and HIA request #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vnovitskyi
Copy link

@vnovitskyi vnovitskyi commented May 15, 2025

This PR adds support for using x509 self-signed certificates in INI and HIA requests.
Details

  • Enables the use of x509 self-signed certificates when handling INI and HIA requests.
  • Updates the generation of init_letter to use certificate data instead of a,x and e keys.
  • Adds support for passing a debug_mode: boolean option to client initialization, allowing easy logging of requests and responses for debugging purposes. When debug_mode is enabled, Faraday’s logger middleware is activated to output request and response bodies to STDOUT

Impact

  • No breaking changes; existing workflows not using certificates remain unaffected.
  • Users can now configure and use certificates for INI and HIA interactions as needed.

The changes are tested on plenty of 🇫🇷 banks: BNP, HSBC, Société Générale, LCL.

EBICS - Guide de mise en œuvre en France

@CLAassistant
Copy link

CLAassistant commented May 15, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@tobischo tobischo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks generally ok. I left some comments for which I would suggest a bit of refactoring. I have no EBICS access with which I could test it.

In case where certificates are being used, it should either be all or nothing. Therefore we should probably validate for that.

We probably also do not need to keep all 3 as attr_accessor variables on the client.

The most important piece that is missing here are usage examples for the README.
Without that, the change is not really complete for something as specific as this.
I would not expect anyone to figure it out by reading the code unless they know that it is already an available feature.

Comment on lines +22 to +24
self.x_509_certificate_a_content = options[:x_509_certificate_a_content]
self.x_509_certificate_x_content = options[:x_509_certificate_x_content]
self.x_509_certificate_e_content = options[:x_509_certificate_e_content]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any case where only one of them should be passed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically, yes—because each request type requires a different x509 certificate. For example, if you only need to make an INI request, you just need x_509_certificate_a_content. For an HIA request, you’ll need both x_509_certificate_x_content and x_509_certificate_y_content.

Nokogiri::XML::Builder.new do |xml|
xml.SignaturePubKeyOrderData('xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#', 'xmlns' => 'http://www.ebics.org/S001') {
xml.SignaturePubKeyInfo {
if x_509_certificate_a
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The x509 xml data looks the same in all 3 places, just using a different input.

I would suggest moving that into a function/method to re-use and shorten the part of the xml document.

attr_accessor :passphrase, :url, :host_id, :user_id, :partner_id, :keys, :keys_content, :locale, :product_name
attr_writer :iban, :bic, :name
attr_accessor :passphrase, :url, :host_id, :user_id, :partner_id, :keys, :keys_content, :locale, :product_name,
:x_509_certificate_a_content, :x_509_certificate_x_content, :x_509_certificate_e_content, :debug_mode
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having individual long method names for each individual certificate does not seem very elegant.

Having the 3 keys combined under 1 method allows for keeping the immediate surface area of the client class way smaller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants