diff options
Diffstat (limited to 'Sluift')
-rw-r--r-- | Sluift/client.cpp | 26 |
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,8 +1,8 @@ /* - * Copyright (c) 2013-2014 Isode Limited. + * Copyright (c) 2013-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <boost/lambda/lambda.hpp> #include <boost/lambda/bind.hpp> @@ -25,12 +25,13 @@ #include <Swiften/Roster/XMPPRoster.h> #include <Swiften/Roster/SetRosterRequest.h> #include <Swiften/Presence/SubscriptionManager.h> #include <Swiften/Roster/XMPPRosterItem.h> #include <Swiften/Queries/IQRouter.h> #include <Swiften/Queries/Requests/GetSoftwareVersionRequest.h> +#include <Swiften/TLS/PKCS12Certificate.h> #include <Sluift/Lua/FunctionRegistration.h> #include <Swiften/Base/foreach.h> #include <Swiften/Base/IDGenerator.h> #include <Sluift/Lua/Check.h> #include <Sluift/Lua/Value.h> #include <Sluift/Lua/Exception.h> @@ -729,12 +730,35 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( std::string node(Lua::checkString(L, 2)); client->getClient()->getDiscoManager()->setCapsNode(Lua::checkString(L, 2)); return 0; } SLUIFT_LUA_FUNCTION_WITH_HELP( + Client, set_certificate, + "Sets a client certificate to use for strong authentication with the server.", + "self\n" + "file PKCS #12 file\n" + "pwd passphrase for the certificate private key\n", + "" +) { + std::string file; + std::string pwd; + int index = 2; + if (!lua_isnoneornil(L, index)) { + file = Lua::checkString(L, index); + ++index; + if (!lua_isnoneornil(L, index)) { + pwd = Lua::checkString(L, index); + ++index; + } + } + getClient(L)->getClient()->setCertificate(boost::make_shared<PKCS12Certificate>(file, createSafeByteArray(pwd))); + return 0; +} + +SLUIFT_LUA_FUNCTION_WITH_HELP( Client, jid, "Returns the JID of this client", "self\n", "" ) { SluiftClient* client = getClient(L); |