Commit Graph

1247 Commits

Author SHA1 Message Date
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
Christian Hohnstaedt
432293ad23 x509name: add module test and fix memory issues
Runing module tests with ASAN makes it easier to tackle mamory issues.
2023-10-15 21:15:28 +02:00
Christian Hohnstaedt
0391e6e27f Warning: 'kIOMasterPortDefault' is deprecated
... first deprecated in macOS 12.

Rename kIOMasterPortDefault -> kIOMainPortDefault
2023-10-15 21:15:28 +02:00
Christian Hohnstaedt
d56d47e7bb Related #405: manage X509_NAME in QSharedPointer 2023-10-15 21:15:28 +02:00
Christian Hohnstaedt
2dd2477d62 Add tests for entropy and asn1time
Make a1time::get*() const, because functions return a pointer
still owned by a1time.
Switch from deprecated setTimeSpec() to setTimeZone(()
2023-10-15 21:15:28 +02:00
Christian Hohnstaedt
7db5b7049e Close #405: member functions of a1int class have memory leaks.
Manage ASN1_INTEGER pointer by QSharedPointer
Add AddressSanitizer config to the tests.
2023-10-13 23:38:23 +02:00
Christian Hohnstaedt
d36b32feac Close #402: Subject Alternative Name not filled by all CN
Iterate over all CN and add them to the SAN.
2023-10-13 00:57:13 +02:00
Christian Hohnstaedt
e2e142e012 Add some moduletests 2023-10-12 23:58:00 +02:00
Christian Hohnstaedt
80416fb0b0 Split basic functions
Extract all functions that only depend on Openssl and QtCore
2023-10-12 23:58:00 +02:00
Christian Hohnstaedt
405bc0cabf Catch invalid-key description error
This results in reasonable error message and behavior
2023-10-09 22:31:29 +02:00
Christian Hohnstaedt
fc0191a512 Disable Public key import when displaying key of cert
Importing the displayed public key of a certificate during
certificate import resulted in a double free.

The "import" flag of the key-details can now forcefully
disable the import button.

Fixing it was way more complex than simply disabling it.

Also add sanity checks for pointers that are not our childs
when creating the QModelIndex
2023-10-08 22:19:18 +02:00
Christian Hohnstaedt
993da2d474 Use C++11 initializers for all non-static class members
When XCA started in 2002, there were no C++ initializers.
Drop explicit initializers from the constructors.

 - Fix indentations of section declarators.
 - Replace NULL by nullptr when feasible.
 - Sort private section: properties first, then methods.
2023-10-08 22:19:18 +02:00
Christian Hohnstaedt
4bfa81d4be More #442: Fix more leaks 2023-10-06 11:56:29 +02:00
Christian Hohnstaedt
a39c94481e main.cpp:cmd_help(): don't use exit(), but return
The exit() call resulted in a segfault when a database was open.
Folowing the "shutdown structure" by exiting at the end of
main circumvents it.
2023-10-05 23:12:40 +02:00
Christian Hohnstaedt
2333b02ddc Close #384: Quick view of certificates without trying to open XCA
The ImportMulti dialog does not show up if there is only
one item to display, but the item is displayed directly.

The displayed items have a new "Import" button to import
directly from the viewed item.

If XCA is called with certs, crls, keys etc. from the commandline
XCA only displays and optionally imports the item if a default
database is given. Afterwards XCA exits.
2023-10-05 23:12:40 +02:00
Christian Hohnstaedt
4a0f90e1b8 Drop unneeded allitems pki collector 2023-09-30 11:24:18 +02:00