Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add smime support #104

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

add smime support #104

wants to merge 10 commits into from

Conversation

640kb
Copy link
Contributor

@640kb 640kb commented Jul 22, 2024

Hello,

as promised in Pull Request #101, here is SMIME support for the master branch.

src/smime.cpp Outdated Show resolved Hide resolved
src/smime.cpp Outdated Show resolved Hide resolved
bool writeMimeMessageBuffer();
bool handleData(PKCS7 *p7, BIO *dataIn, int flags);

MimeMessage *_mimeMessage;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these members should go into a private class, and I think it would be nicer if we could transform a MimeMessage into a SMimeMessage

@@ -93,6 +109,7 @@ target_link_libraries(SimpleMail${PROJECT_VERSION_MAJOR}Qt${QT_VERSION_MAJOR}
PUBLIC
Qt::Core
Qt::Network
${OPENSSL_LIBS}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call target_link_libs() agains instead of variable

@@ -228,6 +231,10 @@ bool MimePart::write(QIODevice *device)
headers.append("; name=\"?UTF-8?B?" + d->contentName.toBase64(QByteArray::Base64Encoding) +
"?=\"");
}
if (headers.contains("signed")) {
headers.append("; protocol=\"application/pkcs7-signature\";");
headers.append("; micalg=sha1");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put on a single line, it seems to have doubled ;


int flags = PKCS7_DETACHED | PKCS7_STREAM | PKCS7_BINARY;

BIO *out = NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null, raw pointers, would be nicer if it was RAII even if with just std::unique_ptr with custom deleter


void SMime::loadPKCS12PrivateKey()
{
QFile file(QString::fromLatin1(_keyfile.toStdString().c_str()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for all these conversions


bool SMime::writeMimeMessageBuffer()
{
QBuffer *buffer = new QBuffer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the stack instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants