Commit Graph

1215 Commits

Author SHA1 Message Date
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
Christian Hohnstaedt
b96951fdfd Improve EVP_PKEY_public_check()
According to the documentation EVP_PKEY_public_check() may
return -2 if the algorithm is not supported.
This has been observed with OpenSSL-1.1.1
2023-09-18 18:14:03 +02:00
Christian
d36eefaa7b Use correct free() function
EVP_PKEY must be freed by EVP_PKEY_free()
2023-09-15 10:48:05 +02:00
Christian
da01866fc2 Templates: Only support PEM like export format
PEM Format supports adding comments in comparison to binary.
Still support reading older, binary formatted templates.
2023-09-10 09:47:45 +02:00
Christian Hohnstaedt
11a88781f9 Merge branch 'vertical-align-fix' of github.com:gentoo90/xca 2023-05-30 18:39:35 +02:00
gentoo90
1e06d60f8e Fix vertical text alignment in the tree views 2023-05-30 18:41:11 +03:00
Christian Hohnstaedt
061f676041 Improve/simplify item import
Unify import functions for some (on_butImport_clicked)
or all (on_butOk_clicked) items.
They both call "importIndexes(const QModelIndexList &indexes)"
containing some or all indexes to import.

db_x509.cpp: Only need to search the treeItem (containing all items
without issuer, not all in the rootItem (containing also certificates
with known issuer)

Re-use "remFromCont()" when stealing items from an other CA.
2023-05-30 14:38:55 +02:00
Christian Hohnstaedt
1176a35fa7 Debugging: allow to select/deselect debug messages
Inspired by the Linux kernels dynamic debugging.
2023-05-28 15:31:33 +02:00
Christian Hohnstaedt
827db695b2 Close #368: error while creating CRL with CA using EC key (ed25519)
This fix differs from the proposal in #368 because the signature
of pki_crl::sign() changed after the 2.4.0 release.

However, I was able to increase the bug impact!
Now it crashed instead of only throwing an error! :-)

The signature of the pki_crl::sign() method changed with
commit 61fa66b129, but C++
"outsmarted" me and automatically transformed the EVP_MD == nullptr
into the digest::constructor(EVP_MD) which crashed on the nullptr.
2023-05-25 22:20:27 +02:00
Christian Hohnstaedt
8f277ea781 x509v3_ext: Improve error-checking
Validate SAN, IAN, AIA, CRLDP during rollout.
Fix tab-switching when validating new certificate context.

Also work with X509_EXTENSION being nullptr
2023-05-25 22:18:48 +02:00