Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KItinerary
Commits
f69bf931
Commit
f69bf931
authored
Dec 05, 2019
by
Volker Krause
Browse files
Improve error handling in VDV certificate downloader
parent
3512144f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/vdv/certs/cert-downloader.cpp
View file @
f69bf931
...
...
@@ -32,8 +32,11 @@ static std::vector<QString> listCerts()
QProcess
proc
;
proc
.
setProgram
(
QStringLiteral
(
"kioclient5"
));
proc
.
setArguments
({
QStringLiteral
(
"ls"
),
QStringLiteral
(
"ldap://ldap-vdv-ion.telesec.de:389/ou=VDV%20KA,o=VDV%20Kernapplikations%20GmbH,c=de"
)});
proc
.
setProcessChannelMode
(
QProcess
::
ForwardedErrorChannel
);
proc
.
start
();
proc
.
waitForFinished
();
if
(
!
proc
.
waitForFinished
()
||
proc
.
exitStatus
()
!=
QProcess
::
NormalExit
)
{
qFatal
(
"Failed to list certificates from LDAP server."
);
}
std
::
vector
<
QString
>
certs
;
for
(
const
auto
&
line
:
proc
.
readAllStandardOutput
().
split
(
'\n'
))
{
...
...
@@ -50,8 +53,11 @@ static void downloadCert(const QString &certName)
QProcess
proc
;
proc
.
setProgram
(
QStringLiteral
(
"kioclient5"
));
proc
.
setArguments
({
QStringLiteral
(
"cat"
),
QStringLiteral
(
"ldap://ldap-vdv-ion.telesec.de:389/cn="
)
+
certName
+
QStringLiteral
(
",ou=VDV%20KA,o=VDV%20Kernapplikations%20GmbH,c=de"
)});
proc
.
setProcessChannelMode
(
QProcess
::
ForwardedErrorChannel
);
proc
.
start
();
proc
.
waitForFinished
();
if
(
!
proc
.
waitForFinished
()
||
proc
.
exitStatus
()
!=
QProcess
::
NormalExit
)
{
qFatal
(
"Failed to download certificate %s from LDAP server."
,
qPrintable
(
certName
));
}
// primitive LDIF parser, would be nicer with something like KLDAP
const
auto
certLdif
=
QString
::
fromUtf8
(
proc
.
readAllStandardOutput
());
...
...
@@ -67,7 +73,9 @@ static void downloadCert(const QString &certName)
static
void
writeQrc
(
const
std
::
vector
<
QString
>
&
certNames
)
{
QFile
qrc
(
QStringLiteral
(
"vdv-certs.qrc"
));
qrc
.
open
(
QFile
::
WriteOnly
);
if
(
!
qrc
.
open
(
QFile
::
WriteOnly
))
{
qFatal
(
"Failed to open file %s: %s"
,
qPrintable
(
qrc
.
fileName
()),
qPrintable
(
qrc
.
errorString
()));
}
qrc
.
write
(
"<RCC>
\n
<qresource prefix=
\"
/org.kde.pim/kitinerary/vdv/certs
\"
>
\n
"
);
for
(
const
auto
&
certName
:
certNames
)
{
qrc
.
write
(
" <file>"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment