Bug 439776

Summary: Aqbanking/Kbanking broken in mingw builds on Windows 7
Product: [Applications] kmymoney Reporter: AndreJ <andre+joost>
Component: packagingAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: REPORTED ---    
Severity: normal CC: cklarson, ralf.habacker
Priority: NOR    
Version: 5.1.3   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: filelist-kmymoney5-5.1+QT511+KF565+20210920+git.c0545bdba.log

Description AndreJ 2021-07-12 08:16:00 UTC
SUMMARY


STEPS TO REPRODUCE
1. Install KMyMoney from https://kmymoney.org/snapshots.php#kmymoney5-aq6
2. Open a kmy file that works with previous version 5.07 and ubuntu
3. Try to update an online account or configure aqbanking

OBSERVED RESULT
Update Account is grayed out, "Configure KBanking/Aqbanking" is missing, although the module Kbanking is listed


EXPECTED RESULT
Update account and configure Aqbanking as working in the previous version, and in a Linux VM.


SOFTWARE/OS VERSIONS
Windows: 7

ADDITIONAL INFORMATION

The bug is in the portable and the installer version. I took
mingw64-kmymoney5-setup-5.1+QT511+KF565+git.20210709T021405.a2cd202d4-lp152.48.2.noarch
which expands to kmymoney5-mingw64-5.1+QT511+KF565+git.20210630T122246.149a0cb61-lp152.43.2-setup.exe

Maybe an older version from 30.Jun.2021 instead of 9.Jul.2021?
Comment 1 Ralf Habacker 2021-09-23 13:00:39 UTC
> Update Account is grayed out, "Configure KBanking/Aqbanking" is missing, although the module Kbanking is listed

It helps to see the debug messages kmymoney generates.

Normally debug messages for KDE applications can be inspected by the dbgview tools from sysinternals, which can be started in front of kmymoney. With newer kmymoney releases debug message are not shown there anymore. Instead they are redirected to a console window, from which kmymoney must be started to see them.
Comment 2 Ralf Habacker 2021-09-23 13:01:20 UTC
With a recent snapshot from the stable branch after starting kmymoney in the "Settings" menu I see an entry "setup aqbanking".

To see, what is working and what not I made sure, that no previous aqbanking config was present.
Then I opened the aqbanking configuration dialog and tried to add users for the given types with the following result:

Adding paypal user seem to work.

Adding a hdbci user also seems to work (the dialog is shown and I can enter values, but not tested with a valid hbci account yet)

Adding "OFX Directconnect" user does not show up a dialog to enter user data and the log says:

7:2021-09-23 14:44:27:aqhbci started
3:2021-09-23 14:44:34:gwenhywfar pathmanager.c:   83: Path "aqhbci/xmldatadir" already exists
7:2021-09-23 14:44:34:aqhbci stopped
3:2021-09-23 14:44:34:gwenhywfar dialog.c:  666: Widget [hbciInitChipcardRadio] not found
3:2021-09-23 14:45:59:aqbanking dlg_setup.c:  830: Could not create dialog (type=0)

Adding "offline" user also does not work - in the log there is shown:

3:2021-09-23 14:53:09:aqbanking dlg_setup.c:  815: Provider [aqnone] not found
Comment 3 AndreJ 2021-09-24 07:59:39 UTC
(In reply to Ralf Habacker from comment #1)
> > Update Account is grayed out, "Configure KBanking/Aqbanking" is missing, although the module Kbanking is listed
> 
> It helps to see the debug messages kmymoney generates.
> 

Running gdb kmymoney in a console window, I get the following error message:

Located plugin "C:/Program Files/kmymoney5-230921/lib/qt5/plugins/kmymoney/kbank
ing.dll" Validity true
...
Loading "C:/Program Files/kmymoney5-230921/lib/qt5/plugins/kmymoney/kbanking.dll
"
Could not load plugin 'C:/Program Files/kmymoney5-230921/lib/qt5/plugins/kmymone
y/kbanking.dll', error: Cannot load library C:\Program Files\kmymoney5-230921\li
b\qt5\plugins\kmymoney\kbanking.dll: Die angegebene Prozedur wurde nicht gefunde
n.

The file kbanking.dll is present, not sure what procedure it is looking for.
Comment 4 Ralf Habacker 2021-09-24 09:46:41 UTC
> Searched plugin "C:/Programs/kmymoney5-230921/lib/qt5/plugins/kmymoney/kbanking.dll" Validity true.

This looks like you are using the 64-bit setup version. You can also try the portable package and/or the 32-bit variant to see if they all behave the same. 

Using the Dependency Walker from https://www.dependencywalker.com/ may give you more insight.
1. download the dependency walker with the same architecture as the installed kmymoney package and unpack it. 
2. start dependency walker and open <kmymoney-install-root>\bin\kmymoney.exe
3. start the profiling 
4. you can see more details afterwards, what happens in case of error

Another problem can be that in the global PATH environment settings, other paths containing dll's with the same filename can be loaded instead.

You can determine this with procexp https://docs.microsoft.com/en-us/sysinternals/downloads/process-explorer.

1. download procexp and unpack it
2. start kmymoney and procexp
3. in the procexp windows select kmymoney in the tree view 
4. in the menu View select the item Bottom View -> DLLs
5. in the bottom view click on the table header and add the column "Path".
6. sort the table by path

*.dll files should be loaded only from kmymoney installation directory or Windows path, e.g. c:\Windows.
Comment 5 AndreJ 2021-09-24 16:12:25 UTC
Using Dependency Walker, , I get an error in libgnutls-30.dll from the kmymoney/bin folder:
"Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module." in module C:\Windows\system32\KERNEL32.DLL. Strange because the same dll is called from other DLLs without any error. I'm working on Windows 7 if that is a problem by now.

So I took the libgnutls-30.dll from a previous KMyMoney 5.07 installation. This requires libnettle-6-2.dll and libhogweed-4-2.dll from the same old installation as well. After that, I can configure aqbanking in the menu, and connect to my bank via aqbanking.
I hope you can find a better workaround.
Comment 6 Ralf Habacker 2021-09-27 07:01:42 UTC
Created attachment 141940 [details]
filelist-kmymoney5-5.1+QT511+KF565+20210920+git.c0545bdba.log

> So I took the libgnutls-30.dll from a previous KMyMoney 5.07 installation.
> This requires libnettle-6-2.dll and libhogweed-4-2.dll from the same old >installation as well.

Looking into a fresh installed binary snapshot package shows me that libgnutls-30.dll and the required libraries libhogweed-6.dll and libnettle-8.dll are present in `bin` subdirectory (see appended file list)

Can you please download an up to date portable package and take a look after unpacking ?
Comment 7 AndreJ 2021-09-27 15:43:06 UTC
(In reply to Ralf Habacker from comment #6)
> Looking into a fresh installed binary snapshot package shows me that
> libgnutls-30.dll and the required libraries libhogweed-6.dll and
> libnettle-8.dll are present in `bin` subdirectory (see appended file list)

Yes, they are present, but libgnutls-30.dll throws the error, and the previuos version of the file requires previous versions of the other two dlls.

Using the 32bit build does not help at all.

I did now a clean installation on Windows 8.1, and KMyMoney works as expected (apart from the missing icons). So it seems to be a Windows 7 issue. The Dependency Walker notes other missing files on Windows 8.1, but this seems not to bother kmymoney.

Strangely, aqbanking works inside the current gnucash 4 build with the same libgnutls-30.dll, while the Gnucash folks claim their version 4.x does not work with Windows 7 anymore.
Comment 8 Ralf Habacker 2021-09-28 11:32:34 UTC
(In reply to AndreJ from comment #7)
> (In reply to Ralf Habacker from comment #6)
> > Looking into a fresh installed binary snapshot package shows me that
> > libgnutls-30.dll and the required libraries libhogweed-6.dll and
> > libnettle-8.dll are present in `bin` subdirectory (see appended file list)
> 
> Yes, they are present, but libgnutls-30.dll throws the error, and the
> previuos version of the file requires previous versions of the other two
> dlls.
> 
> Using the 32bit build does not help at all.
> 
> I did now a clean installation on Windows 8.1, and KMyMoney works as
> expected 
Thanks for investigation.

> (apart from the missing icons).

That is an open issue. 

>  So it seems to be a Windows 7 issue. 

Comparing both dll's showes that the newer libgnutls-30.dll depends on some symbols from the ncrypt.dll system library

	DLL Name: ncrypt.dll
	vma:  Hint/Ord Member-Name Bound-To
	1ea260	    3  BCryptCloseAlgorithmProvider
	1ea280	   29  BCryptGenRandom
	1ea292	   39  BCryptOpenAlgorithmProvider
	1ea2b0	   65  NCryptDecrypt
	1ea2c0	   66  NCryptDeleteKey
	1ea2d2	   76  NCryptFreeObject
	1ea2e6	   77  NCryptGetProperty
	1ea2fa	   84  NCryptOpenKey
	1ea30a	   86  NCryptOpenStorageProvider
	1ea326	   94  NCryptSignHash

At least BCryptCloseAlgorithmProvider was added with Windows Vista (https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptclosealgorithmprovider) and explains why kmymoney could not be loaded on Windows 7.

I will add a note on the snapshot download page referring to the minimum operating system requirements. Maybe there is a solution, but I can not say at this time if it would work with the latest gnutls sources. 

Considering that there is no maintenance for Windows 7 anymore and you can do online banking with KMyMoney, it might not be such a good idea to use this OS version for it.

> The Dependency Walker notes other missing files on Windows 8.1, but
> this seems not to bother kmymoney.

That seems to be normal on Windows :-/

> Strangely, aqbanking works inside the current gnucash 4 build with the same
> libgnutls-30.dll, while the Gnucash folks claim their version 4.x does not
> work with Windows 7 anymore.

That may depend on the way how the libgnutls dll was build. I remember that there is was an option in the source to use a ncrypt/bcrypt emulation layer to support older os. Maybe they used that.
Comment 9 AndreJ 2021-09-30 10:08:02 UTC
(In reply to Ralf Habacker from comment #8)
> At least BCryptCloseAlgorithmProvider was added with Windows Vista
> (https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-
> bcryptclosealgorithmprovider) and explains why kmymoney could not be loaded
> on Windows 7.
> 

But Windows Vista (aka 6.0) was issued before Windows 7, so this should not matter.
Comment 10 Jack 2023-07-05 23:16:48 UTC
I'm assuming this has been fixed, but not sure to close as FIXED or UNMAINTAINED for the old versions.  Would be great if the OP closed as FIXED, otherwise the system will close in 30 (?) days.
Comment 11 AndreJ 2023-07-06 08:10:47 UTC
Tested with a current portable build of KMM 5.1.3 on Windows 7 and no change. The workaround from comment #5 still works for me.

Setting status to UNMAINTAINED since noone is still supporting Windows 7.
Comment 12 Bug Janitor Service 2023-07-21 03:45:06 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 13 Chris Larson 2023-12-04 04:30:23 UTC
Unsure if this merits a new bug report or is merely additional information for this one, so I'm initially piggybacking here.
Experiencing the OP's issue, using a newly install KMyMoney using latest stable build for MacOS, on an Apple Silicon M1 MacBook Pro running Sonoma 14.1. Configure aqbanking is not presented as an option under Settings.

Happy to file this separately, if that's preferred. Happy to provide additional information on request.
Comment 14 Chris Larson 2023-12-04 04:35:42 UTC
(In reply to Chris Larson from comment #13)
> Unsure if this merits a new bug report or is merely additional information
> for this one, so I'm initially piggybacking here.
> Experiencing the OP's issue, using a newly install KMyMoney using latest
> stable build for MacOS, on an Apple Silicon M1 MacBook Pro running Sonoma
> 14.1. Configure aqbanking is not presented as an option under Settings.
> 
> Happy to file this separately, if that's preferred. Happy to provide
> additional information on request.

Latest Stable as of this post: Build 1840 from https://binary-factory.kde.org/view/MacOS/job/KMyMoney_Release_macos/

Aqbanking also seems absent on my machine on Nightly, but as it is Nightly, I'm not sure that merits mention here.