summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger Planas <roger.planas@isode.com>2015-07-20 11:09:59 (GMT)
committerRoger Planas <roger.planas@isode.com>2015-07-21 12:30:00 (GMT)
commit02ecf91d261276ec6f1e46b537ac0e10ebae3170 (patch)
treeca7ac3d8c0b12870f43587f87d1bdcaf7ca0e1f5 /Sluift/client.cpp
parentf10bd4cc1f570b27943d27e536d1dcfbcd55ec6a (diff)
downloadswift-02ecf91d261276ec6f1e46b537ac0e10ebae3170.zip
swift-02ecf91d261276ec6f1e46b537ac0e10ebae3170.tar.bz2
Sluift: Add set_certificate for sluift clients
This patch introduces a 'set_certificate' API for Sluift clients, which it is just a wrapper around Swiften's Core client setCertificate. Test-Information: Generated different user certificates for a user (trusted, untrusted, invalid, expired...) and set M-Link to enable flag 'tls_require_client_cert'. Calling 'set_certificate' with these certificates behaved as expected, either letting the Sluift client to authenticate or not. Also tested caling 'set_certificate' with no parameter, and the certificate was successfully cleared (that is, client would no longer be able to connect) Change-Id: Ieb56d59f7f7c1c7027f0fe56905fb83ac3b25298
Diffstat (limited to 'Sluift/client.cpp')
-rw-r--r--Sluift/client.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/Sluift/client.cpp b/Sluift/client.cpp
index f1fc2c7..813c180 100644
--- a/Sluift/client.cpp
+++ b/Sluift/client.cpp
@@ -1,7 +1,7 @@
1/* 1/*
2 * Copyright (c) 2013-2014 Isode Limited. 2 * Copyright (c) 2013-2015 Isode Limited.
3 * All rights reserved. 3 * All rights reserved.
4 * See the COPYING file for more information. 4 * See the COPYING file for more information.
5 */ 5 */
6 6
7#include <boost/lambda/lambda.hpp> 7#include <boost/lambda/lambda.hpp>
@@ -26,10 +26,11 @@
26#include <Swiften/Roster/SetRosterRequest.h> 26#include <Swiften/Roster/SetRosterRequest.h>
27#include <Swiften/Presence/SubscriptionManager.h> 27#include <Swiften/Presence/SubscriptionManager.h>
28#include <Swiften/Roster/XMPPRosterItem.h> 28#include <Swiften/Roster/XMPPRosterItem.h>
29#include <Swiften/Queries/IQRouter.h> 29#include <Swiften/Queries/IQRouter.h>
30#include <Swiften/Queries/Requests/GetSoftwareVersionRequest.h> 30#include <Swiften/Queries/Requests/GetSoftwareVersionRequest.h>
31#include <Swiften/TLS/PKCS12Certificate.h>
31#include <Sluift/Lua/FunctionRegistration.h> 32#include <Sluift/Lua/FunctionRegistration.h>
32#include <Swiften/Base/foreach.h> 33#include <Swiften/Base/foreach.h>
33#include <Swiften/Base/IDGenerator.h> 34#include <Swiften/Base/IDGenerator.h>
34#include <Sluift/Lua/Check.h> 35#include <Sluift/Lua/Check.h>
35#include <Sluift/Lua/Value.h> 36#include <Sluift/Lua/Value.h>
@@ -730,10 +731,33 @@ SLUIFT_LUA_FUNCTION_WITH_HELP(
730 client->getClient()->getDiscoManager()->setCapsNode(Lua::checkString(L, 2)); 731 client->getClient()->getDiscoManager()->setCapsNode(Lua::checkString(L, 2));
731 return 0; 732 return 0;
732} 733}
733 734
734SLUIFT_LUA_FUNCTION_WITH_HELP( 735SLUIFT_LUA_FUNCTION_WITH_HELP(
736 Client, set_certificate,
737 "Sets a client certificate to use for strong authentication with the server.",
738 "self\n"
739 "file PKCS #12 file\n"
740 "pwd passphrase for the certificate private key\n",
741 ""
742) {
743 std::string file;
744 std::string pwd;
745 int index = 2;
746 if (!lua_isnoneornil(L, index)) {
747 file = Lua::checkString(L, index);
748 ++index;
749 if (!lua_isnoneornil(L, index)) {
750 pwd = Lua::checkString(L, index);
751 ++index;
752 }
753 }
754 getClient(L)->getClient()->setCertificate(boost::make_shared<PKCS12Certificate>(file, createSafeByteArray(pwd)));
755 return 0;
756}
757
758SLUIFT_LUA_FUNCTION_WITH_HELP(
735 Client, jid, 759 Client, jid,
736 "Returns the JID of this client", 760 "Returns the JID of this client",
737 "self\n", 761 "self\n",
738 "" 762 ""
739) { 763) {