Commit Graph

1324 Commits

Author SHA1 Message Date
Christian Hohnstaedt
db55a09a59 Abandon 3DES triggered by #218 Encryption for exported keys
Switch Key export in "Cert+PKCS#8" and "Database dump"
mode from DES3-EDE to AES-256
2024-08-21 10:20:41 +02:00
Christian Hohnstaedt
39da47c217 Drop support of encrypted PVK files.
The RC4 "encryption" is insecure.

The unencrypted PVK key is also insecure, but it does
not give users a false sense of security.
2024-08-20 11:03:27 +02:00
Christian Hohnstaedt
ee48266625 Update OpenSSL versions
Stay with QT 6.6.3 on Windows, because windeployqt
does not deploy the gcc libs with QT 6.7.2
Stay with QT 6.6.3 on MacOS, because the info/warning
message does not show an icon
2024-08-20 11:00:21 +02:00
Christian Hohnstaedt
2060d75f51 Close #395: Flexible Clipboard Export
Generalize the Clipboard format selection
and extend it to certificates.

Certificates may now be exported as chain
or together with private key.

The clipboard format selection also
affects the Drag&Drop content.

The Export->Clipboard men now also shows the
currently selected format export.
2024-04-23 22:01:38 +02:00
Christian Hohnstaedt
e1914d3fd3 Improve translation file lookup on linux
Also look in the directory of the application
if no other translation was found.
Add search path for qt5 or qt6 library translations
depending on the compiletime library version

Use static initializers while at it.
2024-04-23 21:49:39 +02:00
Christian Hohnstaedt
c7565cf0f1 Fix calendar export for CAs
The export checked the F_CHAIN flag, but the export item
used the F_CA flag to indicate CA calendar exports.
2024-04-22 19:13:24 +02:00
Christian Hohnstaedt
e3c2c40f1e Support importing existing OpenVPN TLS Auth keys
The TA-Key is the property of a CA.
2024-04-22 19:13:02 +02:00
Christian Hohnstaedt
f3ed7ef09e Fix missing takeys table in new databases
The "takeys" table was only created for existing databases.

New databases were immediately marked as version "8" databases
and the tykeys table creation was skipped.
2024-04-22 19:13:02 +02:00
Christian Hohnstaedt
7c2a805ede Fix login via PinPad on e.g ReinerSCT
Setting in opensc.conf:
  reader_driver pcsc {
    enable_pinpad = true;
  }

Only call login once and return an empty pin
instead of a NULL pin, which indicated a failure
while an empty (non-NULL) return-value
indicates success.
2024-04-22 19:13:02 +02:00
Christian Hohnstaedt
e72ffb1445 Extend #383: tag insecure PFX/PKCS#12 algorithms
Show the insecure algorithms with the postfix (insecure)
in the dropdown menu.

Since the "insecure" is translateable, put the algorithm NID
into the data field of the combo-box entry to
reliably find the correct entry by NID instead of text.
2024-03-10 18:53:52 +01:00
Christian Hohnstaedt
10e8385c69 Extend #383: support PKCS#12 export format: pbeWithSHA1And40BitRC2-CBC
This ancient, insecure algorithm is apparently
still required by some systems.
2024-03-10 18:53:52 +01:00
Christian Hohnstaedt
b395eaa5cc Close #536: macos include OpenSSL legacy provider
Put it into the "PlugIns" directory and load it from there.
Show whether the legacy-provider was loaded in the About-Dialog.

CmakeLists.txt: Improve OpenSSL Major version detection
and replace the foreach() loop in misc/CMakeLists.txt
by the simpler list(TRANSFORM ...)
2024-03-10 18:53:52 +01:00
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
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
Christian Hohnstaedt
3a73697406 Drop global pointer to mainwin by fixing its last user db_x509
Instead of querying the view about the selected item,
let the view store the current item in the model.
2023-09-30 11:24:18 +02:00
Christian Hohnstaedt
42b76418fb Enable Warnings and fix them 2023-09-30 11:24:18 +02:00
Christian Hohnstaedt
387c238d73 Close #459: pass private key password
The password provided on the command line will be used
as automatic input of the first password dialog.

The database will be opened without requiring a password.
This results in the following bevavior:
  - crl-gen works with:
    o database password
    o private password
    o PIN
  - keygen works with database password
2023-09-30 11:24:18 +02:00
Christian Hohnstaedt
8f05c3eac9 Close #465 Export PEM + Key in one File
Fix logical error when exporting in PEM format.
The key export part was not reached...

The diff is much smaller when displayed with -b to skip
indentation-only changes....

Drop the unused "F_PLUSKEY" flag and fix the Template export
2023-09-30 11:24:18 +02:00
Christian Hohnstaedt
9b749d799b Close #460: Impossible to import PKCS#12 (RC40_CBC)
Unconditionally load the "legacy" provider to be able to
import legacy files like "pbeWithSHA1And40BitRC2-CBC"
encrypted PKCS#12
2023-09-30 11:24:18 +02:00
Christian Hohnstaedt
954eec958a Improve hash selection, especially for ED25519 keys
When using a key with a hash algorithm, check whether
they can be used together. This should have been happened in the GUI.

In case of an error use the largest algorithm
2023-09-30 11:24:18 +02:00
Christian Hohnstaedt
be31b6e22e Make XCA AppStore compliant with -DAPPSTORE_COMPLIANT=ON
APPSTORE_COMPLIANT = ON:
 - Turns off the File menu and moves the language selector to
   the "Extra" Menu. "Options" and "Exit" are at the xca-macos
   special-menu anyway.
 - Switches the signing key from "Developer ID Application" to
   "3rd Party Mac Developer Application"
 - Sets the database name to "default.xdb"
 - Adds "-appstore-compliant" option to macdeployqt
 - Picks the "entitlement-appstore-compliant.plist"
 - Disables the "Token" menu and "PKCS#11 provider" tab
   in the option dialog
2023-09-30 11:24:18 +02:00
Christian Hohnstaedt
270152e708 Add db transaction around the removal of a CA certificate
.. to avoid an error message, enforcing each database write access
into a transaction
2023-09-30 11:24:18 +02:00
Christian Hohnstaedt
e160160395 Fix item search
Caching solution for 186657fbce
was bad. It always returned "visible" when called with unchanged
pattern instead of the last result.  Cache the last result
in "iamvisible": 0=no, 1=yes, 2=one-of-my-children and return
the cached value as long as the search pattern is unchanged.
2023-09-24 13:29:11 +02:00
Christian Hohnstaedt
e39be9b4e9 Close #423: parameter --name is not respected when running with CLI
Evaluate --name argument when generating the CRL.
Add --import-names option. This allows to name the imported items
individually, even if one PEM file contains multiple items.
2023-09-24 00:34:46 +02:00
Christian Hohnstaedt
cccc8ee1e3 Close #440: yellow background makes date text hard to read in dark themes
Adapt red and yellow background colors depending on the used theme,
detected by: "Text color lighter than Background color?"
2023-09-23 12:28:15 +02:00
Christian Hohnstaedt
e8cd69c45d Drop references to iostream
github actions seem to fail because of iostream.

Do not analyze the details for hours, but drop the
last iostream references and hope it helps.

iostream was not the culprit. Keep this change anyway,
since it makes sense and unifies stdout access.
2023-09-23 12:27:00 +02:00
Christian Hohnstaedt
c3f58d402f Close #437: loading CRL at startup generates an error
Extend B64_BLOB from "VARCHAR(8000)" which was a good
common value - until I realized that CRL may become pretty large.

Use "TEXT" for all databases but MariaDB, where LONGTEXT is used.

Add database type check via SQL query to detect the
correct database even behind an ODBC Driver.
2023-09-21 21:42:54 +02:00
Christian Hohnstaedt
65b10c33ce Close #444 cannot update template internal name
Update internal name, even if they seem unchanged
if the force option is set.
2023-09-21 20:58:14 +02:00
Christian Hohnstaedt
03a61dcc2b Fix crash while duplicating templates
A non-empty parent pointer now indicates that this
item is already inserted in the tree-view.
Duplicated templates are not. Do not copy the parent link
in the constructor.
2023-09-20 23:08:54 +02:00
Christian Hohnstaedt
26d5c73806 Improve EVP_PKEY_check()
According to the documentation EVP_PKEY_check() may
return -2 if the algorithm is not supported.
This has been observed with OpenSSL-1.1.1

See also b96951fdfd
2023-09-20 23:03:57 +02:00
Christian Hohnstaedt
c1bee8b38d Close #442: asan checks failed
Enable ASAN with -DADDRESS_SANITIZER=ON
Fix all findings inside XCA.
2023-09-20 21:08:44 +02:00
Christian Hohnstaedt
52f1cf3388 Catch PEM_read_bio_* read errors
If the base64 decoding fails these function return a null pointer
without setting an openssl error.

Additionally throw an error if the PEM_read_bio functions return NULL.
2023-09-20 15:24:28 +02:00
Christian Hohnstaedt
65f2676939 Q_OS_MAC is deprecated 2023-09-19 23:39:03 +02:00
Christian Hohnstaedt
2b59f07b1a Make sure QT_MESSAGELOGCONTEXT is always set. 2023-09-19 23:35:27 +02:00
Christian Hohnstaedt
99a7768fd9 Improve/Fix database loading
Do not interact with the GUI when loading datbase items (beginInsertRows,
beginMoveRows, beginRemoveRows, etc.) by not using
insertChild() / remFromCont() anymore.

Fill and organize the root- tree- and sub-items and call
columnsContentChanged() once when done.

Automatically set "parent" of a pki-item when inserting or removing
as child items.
2023-09-19 16:43:24 +02:00
Christian Hohnstaedt
441bc8630d Really erase element after deleting 2023-09-19 16:42:25 +02:00
Christian Hohnstaedt
dfb2489a78 Select newest issuer when importing certificates
When looking for issuers of an imported certificate, don't use the
first matching, but pick the one with the highest "notAfter" date.
2023-09-19 16:30:28 +02:00