Commit Graph

1262 Commits

Author SHA1 Message Date
Christian Hohnstaedt
1199d776d2 Close #89: ta.key for OpenVPN tls-auth
The ta-key will be generated on-demand and assigned to the
issuing CA. All issued certificates of this CA will use the
same ta-key.

It can be exported as single file and will also be part of the
exported openvpn configuration file.

Extend export tests to validate the output of ta-keys
and adapt the OpenVPN conf file export test to also check the ta-key.
2024-03-04 12:21:00 +01:00
Christian Hohnstaedt
0dd587a3f2 Move OpenSSL configuration file generation
Instead of being a special context menu entry,
make it an option in the export dialog.
2024-03-04 12:21:00 +01:00
Christian Hohnstaedt
06009705bb Close #496: PKCS11 access to AWS CloudHSM failed
It results in CKR_SLOT_ID_INVALID error.

Use CK_SLOT_ID definition (unsigned long)
consistently. It is 64 bit on Linux.

Especially don't mangle it through an 'int'
in line 226 of lib/pkcs11_lib.cpp
2024-02-29 17:57:46 +01:00
Christian Hohnstaedt
4b37902052 Yubikey select one of the special IDs
Yubikey defines and enforces 4 (NEO) or 24 (YubiKey YK4, YubiKey YK5)
slots with special, fixed names.

Add a dropdown box if "fixed_ids" are present and let the user select
the slot during key generation.
2024-02-29 17:57:46 +01:00
Christian Hohnstaedt
844e74632b Yubikey: add p11.tokenLoginForModification()
to encapsulate the most used configuration and
add the need_SO_for_object_mod() function
to establish a SO-login on yubikeys when modifying items..
2024-02-29 17:57:46 +01:00
Christian Hohnstaedt
d52708e5b4 Consolidate Workarounds for special tokens
to document their use ...
2024-02-29 17:57:46 +01:00
Christian Hohnstaedt
7e3b0e12fd Add pkcs11::closeSession() to fix token management
The Yubikey does not like an open read-only session
while changing items with a write-session
2024-02-29 17:57:46 +01:00
Christian Hohnstaedt
46e82e254e Constify tokenInfo() and findUniqueID()
No functional change
2024-02-29 17:57:46 +01:00
Christian Hohnstaedt
2785376689 Fix deletion of dialog pointers
Don't shadow the CertExtend dlg variable to be freed properly
at the end of the function.
Delete revoke dialog after use.
2024-02-23 15:35:22 +01:00
Christian Hohnstaedt
a25b6c7402 Close #520: permanent processor load
Improve the timer interval maintenance process:
 - Do not fire every second,
   but at most 1 second after the last run
 - Reduce the fired events.
 - Every container now only evaluates its own elements
   (keys, certs,etc.) instead of each container evaluating all
   items and duplicating work

Disable sorting and resizing in the view during initialization,
to speed up opening the database
2024-02-23 12:24:31 +01:00
Christian Hohnstaedt
6b9c16a36a PEM Export of keys: Avoid endless loop
calling the pem() function with one argument
would call us (pem() with 2 arguments) again
and we would call him again. This is no good :-)
2024-02-23 12:21:53 +01:00
Christian Hohnstaedt
8587566613 Fix segfault during cmdline import
Tell the calling process that we consumed and free'd
the pki_multi by returning a null-pointer instead of
a dangling pointer to free'd memory.
2024-02-23 12:17:23 +01:00
Christian Hohnstaedt
f9fddc3108 Database schema update: accept newer versions
This actually needs a more sophisticated solution with
schema major.minor version, incrementing the major version
for breaking changes, where old releases should not open newer
databases.

In the past, schema changes were always backward compatible,
i.e. older releases could open newer databases without breaking them.
2024-02-21 23:15:21 +01:00
Christian Hohnstaedt
ec7efed657 Documentation: add information about password format 2024-02-18 23:20:12 +01:00
Christian Hohnstaedt
56a1fdfc57 Fix translation of export format description
Before this change, the export format descriptions were created
statically before any translation has been setup.

Now it is created after the translation is setup and after every
language change.
2024-02-16 17:42:13 +01:00
Christian Hohnstaedt
0d100615d7 Always build tests to ease automatic testing 2024-02-14 22:31:33 +01:00
Christian
a20e810405 Update Windows build to install legacy.dll
Enable legacy provider to allow loading keys
encrypted with an ancient, insecure
algorithm like "pbeWithSHA1And40BitRC2-CBC" for PKCS#12/PFX

Install the dynamic.dll in the portable app and WIX installer.
2024-02-14 22:27:17 +01:00
Christian Hohnstaedt
44be50a42f Change B64_BLOB pattern to make th file parseable again
Otherwise sphinx-build spitts the warning:
  Parsing as "sql" resulted in an error at token: '{'.
  Retrying in relaxed mode.
2024-02-12 21:53:18 +01:00
Christian Hohnstaedt
0a1a21608d Close #518: Export certificates for ovpn file
Create ovpn file with "ca", "cert" and "key"
Additionally put all intermediate CAs (if any)
tagged as "extra-certs".

"tls-auth" "OpenVPN Static key V1" not supported (yet)

Extend export-test by OpenVPN test case
2024-02-11 00:29:01 +01:00
Christian Hohnstaedt
6d01928d5d Automatically transform the key encryption scheme
When opening the database Find legacy encrypted keys and:
 - update them automatically when encrypted with the
   database password or
 - inform the user about a required action when encrypted with an
   individual passphrase

Related issues #458 #511 #503 #500 #494 #484 #482 #475

Remember a complete transformation of all keys
in the Settings["legacy-keys-updated"]
to avoid analyzing all keys each tim a database is opened.
2024-02-10 11:39:43 +01:00
Christian Hohnstaedt
e4483bc48d Move password verify logic into separate function
... and name it validateDatabasePassword().
It will also be used in the next commit to check
if the database password was entered correctly.
2024-02-09 22:46:26 +01:00
Christian Hohnstaedt
286ae96764 Fixup warning introduced with 5dc8e7fd
Fix error: lib/db_x509.cpp:774:4: warning:
           add explicit braces to avoid dangling else [-Wdangling-else]
2024-02-08 17:06:59 +01:00
Christian Hohnstaedt
d32ab2e0d4 Close #458: Re-add support for legacy keys
With 2.5.0 support for decrypting pre 2.0.0 keys was dropped.
However, the database update in 2.0.0 and later did not convert the
keys.

Related issues #458 #511 #503 #500 #494 #484 #482 #475
2024-02-08 16:59:04 +01:00
Christian Hohnstaedt
7d44c561cd Merge branch 'monnerat-delete-after-revoke' 2024-02-06 21:48:34 +01:00
Christian Hohnstaedt
4cb7b206a6 Explicitly set SHA1 based MAC for PKCS12 for legacy algorithm
Related to #512 #474 #481 #506 #509

Co-authored by: littlejon <smithj@servercore.io>
Thanks!
2024-01-31 19:03:02 +01:00
Patrick Monnerat
5dc8e7fd34 Fix a use-after-free crash
When requesting revocation AND deletion of certificates while renewing
them, revocation occurs after deletion, causing a use-after-free
error/crash.

This commit delays the certificates deletion after they have been
revoked.
2024-01-22 08:55:17 +01:00
Christian Hohnstaedt
2f482fc782 pki_base: cache the hash
It will not change for the lifetime of the item.
2024-01-20 08:55:40 +01:00
Christian Hohnstaedt
b6ce91b81c Database schema: use string.replace for TEXT/LONGTEXT
Because generally using QString.arg() results in an error for
strings without %1
Also use the static database() function instead of creating
a temporary instance during close.
2024-01-20 08:54:11 +01:00
Christian Hohnstaedt
f3dc07c00d Testing: reduce test-declaratipn code
by extending the Test() macro
2024-01-16 16:18:57 +01:00
Christian Hohnstaedt
0775dbf113 Move GUI tests to test/ subdir 2024-01-14 23:43:00 +01:00
Christian Hohnstaedt
41ff6818e9 Repeat password input on bad password 2023-12-30 11:02:42 +01:00
Christian Hohnstaedt
0c1c00962f Fix whitespace errors 2023-12-30 11:01:11 +01:00
Christian Hohnstaedt
b9622f8a15 Use QVERIFY where appropriate 2023-12-30 10:05:34 +01:00
Christian Hohnstaedt
5c3f1b3322 Test: add digest-handling test.
The digests itself are tested by OpenSSL
2023-11-03 14:14:18 +01:00
Christian Hohnstaedt
dbe9eaa891 Extend GUI test by PEM import 2023-11-03 13:06:54 +01:00
Christian Hohnstaedt
ec1c233d4f XcaWarning: Make print function virtual
derived classes may simply change the print_cmdline()
function. For example for testing.
2023-11-03 13:04:04 +01:00
Christian Hohnstaedt
89b3914ff7 Split tests in "gui" and "console" tests
Only execute console tests on github actions
2023-11-02 22:06:23 +01:00
Christian Hohnstaedt
143d059ded Take care of OpenSSL and LibreSSL compatibility
OpenSSL 1.1.1 - 3.1.x are supported as well as
LibreSSL 3.6.x
2023-11-02 21:08:44 +01:00
Christian Hohnstaedt
d29d55ab20 Close #477: paste an encrypted private key results in a crash
Improve error- and password handling:
 - Also identify: (ERR_LIB_PROV:PROV_R_BAD_DECRYPT) as password error.
 - Do not use the OpenSSL internal bitfield definition (0xff000fff)
   but the official API: ERR_GET_LIB(), ERR_GET_REASON()
   Especially ERR_LIB_OFFSET changed from 24 to 23 in Openssl 3.0.0
 - First check for "Cancel", then for invalid password to avoid
   an "Invalid Password" message after aborting the password input dialog.
2023-11-02 14:27:58 +01:00
Christian Hohnstaedt
8bd6141f0c Set OpenSSL default UI to not fallback to commandline 2023-11-02 14:05:44 +01:00
Christian Hohnstaedt
b88a20292e Move testxca target to the tests target
and remove it from the default target (all)
2023-11-02 13:50:30 +01:00
Christian Hohnstaedt
1fdc056698 Replace all C_FILE by __FILE__
It was not used consequently anyway
2023-10-31 11:45:16 +01:00
Christian Hohnstaedt
670444391d On GCC and CLANG use -fmacro-prefix-map
and skip the C_FILE strrchr() mess which failed for windows anyway.
2023-10-31 11:00:46 +01:00
Christian Hohnstaedt
41e46c1f51 ASAN: drop more ressources on exit 2023-10-30 20:01:31 +01:00
Christian Hohnstaedt
43e1b336d2 Fix crash when deleting CA certificates
If a CA certificate is deleted, all issued certificates must be moved to
an other issuer or the top-level list.

The CA cert will be taken from the model together with the issued certs
first. Then the issued certs are re-inserted.
To make this work correctly, the issuer must be erased from the issued certs
to be interpreted as insertion and not as move.
2023-10-30 01:17:50 +01:00
Christian Hohnstaedt
4fe06de78b Improve error handling in case of a wrong private password
instead of simply doing nothing.
2023-10-25 20:08:52 +02:00
Christian Hohnstaedt
e3791e2609 Add GUI test - testing the NewKey dialog 2023-10-24 17:03:09 +02:00
Christian Hohnstaedt
f28ab5c3bd Extract cmdline handling from main.cpp 2023-10-16 22:42:36 +02:00
Christian Hohnstaedt
cbaa8eba16 Extract debug_info class from main.cpp 2023-10-16 22:42:36 +02:00
Christian Hohnstaedt
cd1c14893e Revert "Warning: 'kIOMasterPortDefault' is deprecated"
But since we still support macos 10.15 we stick with it.
This reverts commit d0aee7e713c91ad4f0cb1824a4b7bfe09b5325c3.
2023-10-15 21:15:28 +02:00