From 2a272f0aa74ea71cfa97b7fe833c1d263047ffae Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Sat, 23 Dec 2017 07:18:20 -0500 Subject: [PATCH] (feat) added PKCS12 import/removal --- UI/MailerUI/UIxMailAccountActions.h | 2 +- UI/MailerUI/UIxMailAccountActions.m | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/UI/MailerUI/UIxMailAccountActions.h b/UI/MailerUI/UIxMailAccountActions.h index 83f4fc206..0abdbb484 100644 --- a/UI/MailerUI/UIxMailAccountActions.h +++ b/UI/MailerUI/UIxMailAccountActions.h @@ -1,6 +1,6 @@ /* UIxMailAccountActions.h - this file is part of SOGo * - * Copyright (C) 2007-2016 Inverse inc. + * Copyright (C) 2007-2017 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/UI/MailerUI/UIxMailAccountActions.m b/UI/MailerUI/UIxMailAccountActions.m index 2b057c1af..65cf4e032 100644 --- a/UI/MailerUI/UIxMailAccountActions.m +++ b/UI/MailerUI/UIxMailAccountActions.m @@ -1,6 +1,6 @@ /* UIxMailAccountActions.m - this file is part of SOGo * - * Copyright (C) 2007-2016 Inverse inc. + * Copyright (C) 2007-2017 Inverse inc. * * This file is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,6 +37,7 @@ #import #import +#import #import #import #import @@ -198,6 +199,7 @@ NSString *mimeType, *name, *password; WOResponse *response; id data; + unsigned int count, max; password = nil; @@ -217,7 +219,7 @@ name = [header name]; if ([name isEqualToString: @"password"]) { - password = name; + password = [part body]; } else if ([name isEqualToString: @"file"]) { @@ -236,7 +238,18 @@ if (password && pkcs12) { - // TODO: append certificate to user defaults + SOGoUserDefaults *ud; + NSData *certificate; + + certificate = [pkcs12 convertPKCS12ToPEMUsingPassword: password]; + + if (!certificate) + return [self responseWithStatus: 507]; + + ud = [[context activeUser] userDefaults]; + [[self clientObject] setCertificate: certificate]; + [ud synchronize]; + response = [self responseWith204]; } @@ -245,7 +258,12 @@ - (WOResponse *) removeCertificateAction { - // TODO: remove certificate from user defaults + SOGoUserDefaults *ud; + + ud = [[context activeUser] userDefaults]; + [[self clientObject] setCertificate: nil]; + [ud synchronize]; + return [self responseWith204]; }