* @param role The role of the client.
* @param sslContext The SSL context for the client.
*/
-TlsStream::TlsStream(const Socket::Ptr& socket, const String& hostname, ConnectionRole role, const boost::shared_ptr<SSL_CTX>& sslContext)
+TlsStream::TlsStream(const Socket::Ptr& socket, const String& hostname, ConnectionRole role, const std::shared_ptr<SSL_CTX>& sslContext)
: SocketEvents(socket, this), m_Eof(false), m_HandshakeOK(false), m_VerifyOK(true), m_ErrorCode(0),
m_ErrorOccurred(false), m_Socket(socket), m_Role(role), m_SendQ(new FIFO()), m_RecvQ(new FIFO()),
m_CurrentAction(TlsActionNone), m_Retry(false), m_Shutdown(false)
std::ostringstream msgbuf;
char errbuf[120];
- m_SSL = boost::shared_ptr<SSL>(SSL_new(sslContext.get()), SSL_free);
+ m_SSL = std::shared_ptr<SSL>(SSL_new(sslContext.get()), SSL_free);
if (!m_SSL) {
msgbuf << "SSL_new() failed with code " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
*
* @returns The X509 certificate.
*/
-boost::shared_ptr<X509> TlsStream::GetClientCertificate(void) const
+std::shared_ptr<X509> TlsStream::GetClientCertificate(void) const
{
boost::mutex::scoped_lock lock(m_Mutex);
- return boost::shared_ptr<X509>(SSL_get_certificate(m_SSL.get()), &Utility::NullDeleter);
+ return std::shared_ptr<X509>(SSL_get_certificate(m_SSL.get()), &Utility::NullDeleter);
}
/**
*
* @returns The X509 certificate.
*/
-boost::shared_ptr<X509> TlsStream::GetPeerCertificate(void) const
+std::shared_ptr<X509> TlsStream::GetPeerCertificate(void) const
{
boost::mutex::scoped_lock lock(m_Mutex);
- return boost::shared_ptr<X509>(SSL_get_peer_certificate(m_SSL.get()), X509_free);
+ return std::shared_ptr<X509>(SSL_get_peer_certificate(m_SSL.get()), X509_free);
}
void TlsStream::OnEvent(int revents)
public:
DECLARE_PTR_TYPEDEFS(TlsStream);
- TlsStream(const Socket::Ptr& socket, const String& hostname, ConnectionRole role, const boost::shared_ptr<SSL_CTX>& sslContext = MakeSSLContext());
+ TlsStream(const Socket::Ptr& socket, const String& hostname, ConnectionRole role, const std::shared_ptr<SSL_CTX>& sslContext = MakeSSLContext());
~TlsStream(void);
Socket::Ptr GetSocket(void) const;
- boost::shared_ptr<X509> GetClientCertificate(void) const;
- boost::shared_ptr<X509> GetPeerCertificate(void) const;
+ std::shared_ptr<X509> GetClientCertificate(void) const;
+ std::shared_ptr<X509> GetPeerCertificate(void) const;
void Handshake(void);
String GetVerifyError(void) const;
private:
- boost::shared_ptr<SSL> m_SSL;
+ std::shared_ptr<SSL> m_SSL;
bool m_Eof;
mutable boost::mutex m_Mutex;
mutable boost::condition_variable m_CV;
* @param cakey CA certificate chain file.
* @returns An SSL context.
*/
-boost::shared_ptr<SSL_CTX> MakeSSLContext(const String& pubkey, const String& privkey, const String& cakey)
+std::shared_ptr<SSL_CTX> MakeSSLContext(const String& pubkey, const String& privkey, const String& cakey)
{
char errbuf[120];
InitializeOpenSSL();
- boost::shared_ptr<SSL_CTX> sslContext = boost::shared_ptr<SSL_CTX>(SSL_CTX_new(SSLv23_method()), SSL_CTX_free);
+ std::shared_ptr<SSL_CTX> sslContext = std::shared_ptr<SSL_CTX>(SSL_CTX_new(SSLv23_method()), SSL_CTX_free);
EC_KEY *ecdh = EC_KEY_new_by_curve_name(NID_secp384r1);
* @param context The ssl context.
* @param cipherList The ciper list.
**/
-void SetCipherListToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& cipherList)
+void SetCipherListToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& cipherList)
{
char errbuf[256];
* @param context The ssl context.
* @param tlsProtocolmin The minimum TLS protocol version.
*/
-void SetTlsProtocolminToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& tlsProtocolmin)
+void SetTlsProtocolminToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& tlsProtocolmin)
{
long flags = SSL_CTX_get_options(context.get());
* @param context The SSL context.
* @param crlPath The path to the CRL file.
*/
-void AddCRLToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& crlPath)
+void AddCRLToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& crlPath)
{
char errbuf[120];
X509_STORE *x509_store = SSL_CTX_get_cert_store(context.get());
* @param certificate The X509 certificate.
* @returns The common name.
*/
-String GetCertificateCN(const boost::shared_ptr<X509>& certificate)
+String GetCertificateCN(const std::shared_ptr<X509>& certificate)
{
return GetX509NameCN(X509_get_subject_name(certificate.get()));
}
* @param pemfile The filename.
* @returns An X509 certificate.
*/
-boost::shared_ptr<X509> GetX509Certificate(const String& pemfile)
+std::shared_ptr<X509> GetX509Certificate(const String& pemfile)
{
char errbuf[120];
X509 *cert;
BIO_free(fpcert);
- return boost::shared_ptr<X509>(cert, X509_free);
+ return std::shared_ptr<X509>(cert, X509_free);
}
int MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile, const String& certfile, bool ca)
X509_NAME *subject = X509_NAME_new();
X509_NAME_add_entry_by_txt(subject, "CN", MBSTRING_ASC, (unsigned char *)cn.CStr(), -1, -1, 0);
- boost::shared_ptr<X509> cert = CreateCert(key, subject, subject, key, ca);
+ std::shared_ptr<X509> cert = CreateCert(key, subject, subject, key, ca);
X509_NAME_free(subject);
return 1;
}
-boost::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca)
+std::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca)
{
X509 *cert = X509_new();
X509_set_version(cert, 2);
X509_sign(cert, cakey, EVP_sha256());
- return boost::shared_ptr<X509>(cert, X509_free);
+ return std::shared_ptr<X509>(cert, X509_free);
}
String GetIcingaCADir(void)
return Application::GetLocalStateDir() + "/lib/icinga2/ca";
}
-boost::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject)
+std::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject)
{
char errbuf[120];
if (!cakeybio) {
Log(LogCritical, "SSL")
<< "Could not open CA key file '" << cakeyfile << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
- return boost::shared_ptr<X509>();
+ return std::shared_ptr<X509>();
}
EVP_PKEY *privkey = PEM_read_bio_PrivateKey(cakeybio, NULL, NULL, NULL);
if (!privkey) {
Log(LogCritical, "SSL")
<< "Could not read private key from CA key file '" << cakeyfile << "': " << ERR_peek_error() << ", \"" << ERR_error_string(ERR_peek_error(), errbuf) << "\"";
- return boost::shared_ptr<X509>();
+ return std::shared_ptr<X509>();
}
BIO_free(cakeybio);
String cacertfile = cadir + "/ca.crt";
- boost::shared_ptr<X509> cacert = GetX509Certificate(cacertfile);
+ std::shared_ptr<X509> cacert = GetX509Certificate(cacertfile);
return CreateCert(pubkey, subject, X509_get_subject_name(cacert.get()), privkey, false);
}
-boost::shared_ptr<X509> CreateCertIcingaCA(const boost::shared_ptr<X509>& cert)
+std::shared_ptr<X509> CreateCertIcingaCA(const std::shared_ptr<X509>& cert)
{
- boost::shared_ptr<EVP_PKEY> pkey = boost::shared_ptr<EVP_PKEY>(X509_get_pubkey(cert.get()), EVP_PKEY_free);
+ std::shared_ptr<EVP_PKEY> pkey = std::shared_ptr<EVP_PKEY>(X509_get_pubkey(cert.get()), EVP_PKEY_free);
return CreateCertIcingaCA(pkey.get(), X509_get_subject_name(cert.get()));
}
-String CertificateToString(const boost::shared_ptr<X509>& cert)
+String CertificateToString(const std::shared_ptr<X509>& cert)
{
BIO *mem = BIO_new(BIO_s_mem());
PEM_write_bio_X509(mem, cert.get());
return result;
}
-boost::shared_ptr<X509> StringToCertificate(const String& cert)
+std::shared_ptr<X509> StringToCertificate(const String& cert)
{
BIO *bio = BIO_new(BIO_s_mem());
BIO_write(bio, (const void *)cert.CStr(), cert.GetLength());
if (!rawCert)
BOOST_THROW_EXCEPTION(std::invalid_argument("The specified X509 certificate is invalid."));
- return boost::shared_ptr<X509>(rawCert, X509_free);
+ return std::shared_ptr<X509>(rawCert, X509_free);
}
String PBKDF2_SHA1(const String& password, const String& salt, int iterations)
return result;
}
-bool VerifyCertificate(const boost::shared_ptr<X509>& caCertificate, const boost::shared_ptr<X509>& certificate)
+bool VerifyCertificate(const std::shared_ptr<X509>& caCertificate, const std::shared_ptr<X509>& certificate)
{
X509_STORE *store = X509_STORE_new();
#include <openssl/x509v3.h>
#include <openssl/evp.h>
#include <openssl/rand.h>
-#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/exception/info.hpp>
namespace icinga
{
void I2_BASE_API InitializeOpenSSL(void);
-boost::shared_ptr<SSL_CTX> I2_BASE_API MakeSSLContext(const String& pubkey = String(), const String& privkey = String(), const String& cakey = String());
-void I2_BASE_API AddCRLToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& crlPath);
-void I2_BASE_API SetCipherListToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& cipherList);
-void I2_BASE_API SetTlsProtocolminToSSLContext(const boost::shared_ptr<SSL_CTX>& context, const String& tlsProtocolmin);
-String I2_BASE_API GetCertificateCN(const boost::shared_ptr<X509>& certificate);
-boost::shared_ptr<X509> I2_BASE_API GetX509Certificate(const String& pemfile);
+std::shared_ptr<SSL_CTX> I2_BASE_API MakeSSLContext(const String& pubkey = String(), const String& privkey = String(), const String& cakey = String());
+void I2_BASE_API AddCRLToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& crlPath);
+void I2_BASE_API SetCipherListToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& cipherList);
+void I2_BASE_API SetTlsProtocolminToSSLContext(const std::shared_ptr<SSL_CTX>& context, const String& tlsProtocolmin);
+String I2_BASE_API GetCertificateCN(const std::shared_ptr<X509>& certificate);
+std::shared_ptr<X509> I2_BASE_API GetX509Certificate(const String& pemfile);
int I2_BASE_API MakeX509CSR(const String& cn, const String& keyfile, const String& csrfile = String(), const String& certfile = String(), bool ca = false);
-boost::shared_ptr<X509> I2_BASE_API CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca);
+std::shared_ptr<X509> I2_BASE_API CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME *issuer, EVP_PKEY *cakey, bool ca);
String I2_BASE_API GetIcingaCADir(void);
-String I2_BASE_API CertificateToString(const boost::shared_ptr<X509>& cert);
-boost::shared_ptr<X509> I2_BASE_API StringToCertificate(const String& cert);
-boost::shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject);
-boost::shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(const boost::shared_ptr<X509>& cert);
+String I2_BASE_API CertificateToString(const std::shared_ptr<X509>& cert);
+std::shared_ptr<X509> I2_BASE_API StringToCertificate(const String& cert);
+std::shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject);
+std::shared_ptr<X509> I2_BASE_API CreateCertIcingaCA(const std::shared_ptr<X509>& cert);
String I2_BASE_API PBKDF2_SHA1(const String& password, const String& salt, int iterations);
String I2_BASE_API SHA1(const String& s, bool binary = false);
String I2_BASE_API SHA256(const String& s);
String I2_BASE_API RandomString(int length);
-bool I2_BASE_API VerifyCertificate(const boost::shared_ptr<X509>& caCertificate, const boost::shared_ptr<X509>& certificate);
+bool I2_BASE_API VerifyCertificate(const std::shared_ptr<X509>& caCertificate, const std::shared_ptr<X509>& certificate);
class I2_BASE_API openssl_error : virtual public std::exception, virtual public boost::exception { };
String certRequestText = request->Get("cert_request");
- boost::shared_ptr<X509> certRequest = StringToCertificate(certRequestText);
+ std::shared_ptr<X509> certRequest = StringToCertificate(certRequestText);
if (!certRequest) {
Log(LogCritical, "cli", "Certificate request is invalid. Could not parse X.509 certificate for the 'cert_request' attribute.");
return 1;
}
- boost::shared_ptr<X509> certResponse = CreateCertIcingaCA(certRequest);
+ std::shared_ptr<X509> certResponse = CreateCertIcingaCA(certRequest);
BIO *out = BIO_new(BIO_s_mem());
X509_NAME_print_ex(out, X509_get_subject_name(certRequest.get()), 0, XN_FLAG_ONELINE & ~ASN1_STRFLGS_ESC_MSB);
return 1;
}
- boost::shared_ptr<X509> trustedcert = GetX509Certificate(vm["trustedcert"].as<std::string>());
+ std::shared_ptr<X509> trustedcert = GetX509Certificate(vm["trustedcert"].as<std::string>());
Log(LogInformation, "cli")
<< "Verifying trusted certificate file '" << vm["trustedcert"].as<std::string>() << "'.";
<< "' on file '" << nodeKey << "'. Verify it yourself!";
}
- boost::shared_ptr<X509> trustedParentCert;
+ std::shared_ptr<X509> trustedParentCert;
/* Check whether we should connect to the parent node and present its trusted certificate. */
if (connectToParent) {
Log(LogInformation, "cli")
<< "Retrieving X.509 certificate for '" << host << ":" << port << "'.";
- boost::shared_ptr<X509> cert = PkiUtility::FetchCert(host, port);
+ std::shared_ptr<X509> cert = PkiUtility::FetchCert(host, port);
if (!cert) {
Log(LogCritical, "cli", "Failed to fetch certificate from host.");
ApplyRule::RuleMap ApplyRule::m_Rules;
ApplyRule::TypeMap ApplyRule::m_Types;
-ApplyRule::ApplyRule(const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression,
- const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
+ApplyRule::ApplyRule(const String& targetType, const String& name, const std::shared_ptr<Expression>& expression,
+ const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm,
bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
: m_TargetType(targetType), m_Name(name), m_Expression(expression), m_Filter(filter), m_Package(package), m_FKVar(fkvar),
m_FVVar(fvvar), m_FTerm(fterm), m_IgnoreOnError(ignoreOnError), m_DebugInfo(di), m_Scope(scope), m_HasMatches(false)
return m_Name;
}
-boost::shared_ptr<Expression> ApplyRule::GetExpression(void) const
+std::shared_ptr<Expression> ApplyRule::GetExpression(void) const
{
return m_Expression;
}
-boost::shared_ptr<Expression> ApplyRule::GetFilter(void) const
+std::shared_ptr<Expression> ApplyRule::GetFilter(void) const
{
return m_Filter;
}
return m_FVVar;
}
-boost::shared_ptr<Expression> ApplyRule::GetFTerm(void) const
+std::shared_ptr<Expression> ApplyRule::GetFTerm(void) const
{
return m_FTerm;
}
}
void ApplyRule::AddRule(const String& sourceType, const String& targetType, const String& name,
- const boost::shared_ptr<Expression>& expression, const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar,
- const String& fvvar, const boost::shared_ptr<Expression>& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
+ const std::shared_ptr<Expression>& expression, const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar,
+ const String& fvvar, const std::shared_ptr<Expression>& fterm, bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope)
{
m_Rules[sourceType].push_back(ApplyRule(targetType, name, expression, filter, package, fkvar, fvvar, fterm, ignoreOnError, di, scope));
}
String GetTargetType(void) const;
String GetName(void) const;
- boost::shared_ptr<Expression> GetExpression(void) const;
- boost::shared_ptr<Expression> GetFilter(void) const;
+ std::shared_ptr<Expression> GetExpression(void) const;
+ std::shared_ptr<Expression> GetFilter(void) const;
String GetPackage(void) const;
String GetFKVar(void) const;
String GetFVVar(void) const;
- boost::shared_ptr<Expression> GetFTerm(void) const;
+ std::shared_ptr<Expression> GetFTerm(void) const;
bool GetIgnoreOnError(void) const;
DebugInfo GetDebugInfo(void) const;
Dictionary::Ptr GetScope(void) const;
bool EvaluateFilter(ScriptFrame& frame) const;
- static void AddRule(const String& sourceType, const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression,
- const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
+ static void AddRule(const String& sourceType, const String& targetType, const String& name, const std::shared_ptr<Expression>& expression,
+ const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm,
bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope);
static std::vector<ApplyRule>& GetRules(const String& type);
private:
String m_TargetType;
String m_Name;
- boost::shared_ptr<Expression> m_Expression;
- boost::shared_ptr<Expression> m_Filter;
+ std::shared_ptr<Expression> m_Expression;
+ std::shared_ptr<Expression> m_Filter;
String m_Package;
String m_FKVar;
String m_FVVar;
- boost::shared_ptr<Expression> m_FTerm;
+ std::shared_ptr<Expression> m_FTerm;
bool m_IgnoreOnError;
DebugInfo m_DebugInfo;
Dictionary::Ptr m_Scope;
static TypeMap m_Types;
static RuleMap m_Rules;
- ApplyRule(const String& targetType, const String& name, const boost::shared_ptr<Expression>& expression,
- const boost::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm,
+ ApplyRule(const String& targetType, const String& name, const std::shared_ptr<Expression>& expression,
+ const std::shared_ptr<Expression>& filter, const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm,
bool ignoreOnError, const DebugInfo& di, const Dictionary::Ptr& scope);
};
static bool HasZoneConfigAuthority(const String& zoneName);
private:
- std::promise<boost::shared_ptr<Expression> > m_Promise;
+ std::promise<std::shared_ptr<Expression> > m_Promise;
String m_Path;
std::istream *m_Input;
* @param debuginfo Debug information.
*/
ConfigItem::ConfigItem(const Type::Ptr& type, const String& name,
- bool abstract, const boost::shared_ptr<Expression>& exprl,
- const boost::shared_ptr<Expression>& filter, bool defaultTmpl, bool ignoreOnError,
+ bool abstract, const std::shared_ptr<Expression>& exprl,
+ const std::shared_ptr<Expression>& filter, bool defaultTmpl, bool ignoreOnError,
const DebugInfo& debuginfo, const Dictionary::Ptr& scope,
const String& zone, const String& package)
: m_Type(type), m_Name(name), m_Abstract(abstract),
*
* @returns The expression list.
*/
-boost::shared_ptr<Expression> ConfigItem::GetExpression(void) const
+std::shared_ptr<Expression> ConfigItem::GetExpression(void) const
{
return m_Expression;
}
*
* @returns The filter expression.
*/
-boost::shared_ptr<Expression> ConfigItem::GetFilter(void) const
+std::shared_ptr<Expression> ConfigItem::GetFilter(void) const
{
return m_Filter;
}
DECLARE_PTR_TYPEDEFS(ConfigItem);
ConfigItem(const Type::Ptr& type, const String& name, bool abstract,
- const boost::shared_ptr<Expression>& exprl,
- const boost::shared_ptr<Expression>& filter,
+ const std::shared_ptr<Expression>& exprl,
+ const std::shared_ptr<Expression>& filter,
bool defaultTmpl, bool ignoreOnError, const DebugInfo& debuginfo,
const Dictionary::Ptr& scope, const String& zone,
const String& package);
std::vector<ConfigItem::Ptr> GetParents(void) const;
- boost::shared_ptr<Expression> GetExpression(void) const;
- boost::shared_ptr<Expression> GetFilter(void) const;
+ std::shared_ptr<Expression> GetExpression(void) const;
+ std::shared_ptr<Expression> GetFilter(void) const;
void Register(void);
void Unregister(void);
String m_Name; /**< The name. */
bool m_Abstract; /**< Whether this is a template. */
- boost::shared_ptr<Expression> m_Expression;
- boost::shared_ptr<Expression> m_Filter;
+ std::shared_ptr<Expression> m_Expression;
+ std::shared_ptr<Expression> m_Filter;
bool m_DefaultTmpl;
bool m_IgnoreOnError;
DebugInfo m_DebugInfo; /**< Debug information. */
#include "config/configitembuilder.hpp"
#include "base/configtype.hpp"
#include <sstream>
-#include <boost/smart_ptr/make_shared.hpp>
using namespace icinga;
m_Expressions.push_back(expr);
}
-void ConfigItemBuilder::SetFilter(const boost::shared_ptr<Expression>& filter)
+void ConfigItemBuilder::SetFilter(const std::shared_ptr<Expression>& filter)
{
m_Filter = filter;
}
}
#endif /* I2_DEBUG */
- boost::shared_ptr<DictExpression> exprl = boost::make_shared<DictExpression>(exprs, m_DebugInfo);
+ std::shared_ptr<DictExpression> exprl = std::make_shared<DictExpression>(exprs, m_DebugInfo);
exprl->MakeInline();
return new ConfigItem(m_Type, m_Name, m_Abstract, exprl, m_Filter,
void SetIgnoreOnError(bool ignoreOnError);
void AddExpression(Expression *expr);
- void SetFilter(const boost::shared_ptr<Expression>& filter);
+ void SetFilter(const std::shared_ptr<Expression>& filter);
ConfigItem::Ptr Compile(void);
String m_Name; /**< The name. */
bool m_Abstract; /**< Whether the item is abstract. */
std::vector<Expression *> m_Expressions; /**< Expressions for this item. */
- boost::shared_ptr<Expression> m_Filter; /**< Filter expression. */
+ std::shared_ptr<Expression> m_Filter; /**< Filter expression. */
DebugInfo m_DebugInfo; /**< Debug information. */
Dictionary::Ptr m_Scope; /**< variable scope. */
String m_Zone; /**< The zone. */
class I2_CONFIG_API OwnedExpression : public Expression
{
public:
- OwnedExpression(const boost::shared_ptr<Expression>& expression)
+ OwnedExpression(const std::shared_ptr<Expression>& expression)
: m_Expression(expression)
{ }
}
private:
- boost::shared_ptr<Expression> m_Expression;
+ std::shared_ptr<Expression> m_Expression;
};
class I2_CONFIG_API LiteralExpression : public Expression
String m_Name;
std::vector<String> m_Args;
std::map<String, Expression *> *m_ClosedVars;
- boost::shared_ptr<Expression> m_Expression;
+ std::shared_ptr<Expression> m_Expression;
};
class I2_CONFIG_API ApplyExpression : public DebuggableExpression
String m_Type;
String m_Target;
Expression *m_Name;
- boost::shared_ptr<Expression> m_Filter;
+ std::shared_ptr<Expression> m_Filter;
String m_Package;
String m_FKVar;
String m_FVVar;
- boost::shared_ptr<Expression> m_FTerm;
+ std::shared_ptr<Expression> m_FTerm;
bool m_IgnoreOnError;
std::map<String, Expression *> *m_ClosedVars;
- boost::shared_ptr<Expression> m_Expression;
+ std::shared_ptr<Expression> m_Expression;
};
class I2_CONFIG_API ObjectExpression : public DebuggableExpression
bool m_Abstract;
Expression *m_Type;
Expression *m_Name;
- boost::shared_ptr<Expression> m_Filter;
+ std::shared_ptr<Expression> m_Filter;
String m_Zone;
String m_Package;
bool m_DefaultTmpl;
bool m_IgnoreOnError;
std::map<String, Expression *> *m_ClosedVars;
- boost::shared_ptr<Expression> m_Expression;
+ std::shared_ptr<Expression> m_Expression;
};
class I2_CONFIG_API ForExpression : public DebuggableExpression
#include "base/exception.hpp"
#include "base/convert.hpp"
#include "base/objectlock.hpp"
-#include <boost/smart_ptr/make_shared.hpp>
#include <map>
#include <vector>
}
static inline Value NewFunction(ScriptFrame& frame, const String& name, const std::vector<String>& argNames,
- std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression)
+ std::map<String, Expression *> *closedVars, const std::shared_ptr<Expression>& expression)
{
auto evaluatedClosedVars = EvaluateClosedVars(frame, closedVars);
return new Function(name, wrapper, argNames);
}
- static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const boost::shared_ptr<Expression>& filter,
- const String& package, const String& fkvar, const String& fvvar, const boost::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars,
- bool ignoreOnError, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
+ static inline Value NewApply(ScriptFrame& frame, const String& type, const String& target, const String& name, const std::shared_ptr<Expression>& filter,
+ const String& package, const String& fkvar, const String& fvvar, const std::shared_ptr<Expression>& fterm, std::map<String, Expression *> *closedVars,
+ bool ignoreOnError, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
{
ApplyRule::AddRule(type, target, name, expression, filter, package, fkvar,
fvvar, fterm, ignoreOnError, debugInfo, EvaluateClosedVars(frame, closedVars));
return Empty;
}
- static inline Value NewObject(ScriptFrame& frame, bool abstract, const Type::Ptr& type, const String& name, const boost::shared_ptr<Expression>& filter,
- const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, std::map<String, Expression *> *closedVars, const boost::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
+ static inline Value NewObject(ScriptFrame& frame, bool abstract, const Type::Ptr& type, const String& name, const std::shared_ptr<Expression>& filter,
+ const String& zone, const String& package, bool defaultTmpl, bool ignoreOnError, std::map<String, Expression *> *closedVars, const std::shared_ptr<Expression>& expression, const DebugInfo& debugInfo = DebugInfo())
{
ConfigItemBuilder::Ptr item = new ConfigItemBuilder(debugInfo);
namespace icinga
{
-typedef boost::shared_ptr<MYSQL_RES> IdoMysqlResult;
+typedef std::shared_ptr<MYSQL_RES> IdoMysqlResult;
typedef std::function<void (const IdoMysqlResult&)> IdoAsyncCallback;
namespace icinga
{
-typedef boost::shared_ptr<PGresult> IdoPgsqlResult;
+typedef std::shared_ptr<PGresult> IdoPgsqlResult;
/**
* An IDO pgSQL database connection.
}
if (GetEnableTls()) {
- boost::shared_ptr<SSL_CTX> sslContext;
+ std::shared_ptr<SSL_CTX> sslContext;
try {
sslContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath());
}
if (GetSslEnable()) {
- boost::shared_ptr<SSL_CTX> sslContext;
+ std::shared_ptr<SSL_CTX> sslContext;
try {
sslContext = MakeSSLContext(GetSslCert(), GetSslKey(), GetSslCaCert());
} catch (const std::exception& ex) {
url->SetPath(path);
try {
- boost::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
+ std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
req->RequestMethod = "GET";
req->RequestUrl = url;
req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password));
url->SetQuery(params);
try {
- boost::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
+ std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
req->RequestMethod = "GET";
req->RequestUrl = url;
req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password));
url->SetQuery(params);
try {
- boost::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
+ std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
req->RequestMethod = "POST";
req->RequestUrl = url;
req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password));
url->SetQuery(params);
try {
- boost::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
+ std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
req->RequestMethod = "POST";
req->RequestUrl = url;
req->AddHeader("Authorization", "Basic " + Base64::Encode(m_User + ":" + m_Password));
}
/* set up SSL context */
- boost::shared_ptr<X509> cert;
+ std::shared_ptr<X509> cert;
try {
cert = GetX509Certificate(defaultCertPath);
} catch (const std::exception&) {
void ApiListener::UpdateSSLContext(void)
{
- boost::shared_ptr<SSL_CTX> context;
+ std::shared_ptr<SSL_CTX> context;
try {
context = MakeSSLContext(GetDefaultCertPath(), GetDefaultKeyPath(), GetDefaultCaPath());
{
ObjectLock olock(this);
- boost::shared_ptr<SSL_CTX> sslContext = m_SSLContext;
+ std::shared_ptr<SSL_CTX> sslContext = m_SSLContext;
if (!sslContext) {
Log(LogCritical, "ApiListener", "SSL context is required for AddListener()");
{
ObjectLock olock(this);
- boost::shared_ptr<SSL_CTX> sslContext = m_SSLContext;
+ std::shared_ptr<SSL_CTX> sslContext = m_SSLContext;
if (!sslContext) {
Log(LogCritical, "ApiListener", "SSL context is required for AddConnection()");
return;
}
- boost::shared_ptr<X509> cert = tlsStream->GetPeerCertificate();
+ std::shared_ptr<X509> cert = tlsStream->GetPeerCertificate();
String identity;
Endpoint::Ptr endpoint;
bool verify_ok = false;
virtual void ValidateTlsProtocolmin(const String& value, const ValidationUtils& utils) override;
private:
- boost::shared_ptr<SSL_CTX> m_SSLContext;
+ std::shared_ptr<SSL_CTX> m_SSLContext;
std::set<TcpSocket::Ptr> m_Servers;
mutable boost::mutex m_AnonymousClientsLock;
#include "base/tcpsocket.hpp"
#include "base/tlsstream.hpp"
#include "base/networkstream.hpp"
-#include <boost/smart_ptr/make_shared.hpp>
using namespace icinga;
return false;
}
- const std::pair<boost::shared_ptr<HttpRequest>, HttpCompletionCallback>& currentRequest = *m_Requests.begin();
+ const std::pair<std::shared_ptr<HttpRequest>, HttpCompletionCallback>& currentRequest = *m_Requests.begin();
HttpRequest& request = *currentRequest.first.get();
const HttpCompletionCallback& callback = currentRequest.second;
if (!m_CurrentResponse)
- m_CurrentResponse = boost::make_shared<HttpResponse>(m_Stream, request);
+ m_CurrentResponse = std::make_shared<HttpResponse>(m_Stream, request);
- boost::shared_ptr<HttpResponse> currentResponse = m_CurrentResponse;
+ std::shared_ptr<HttpResponse> currentResponse = m_CurrentResponse;
HttpResponse& response = *currentResponse.get();
try {
m_Stream->Close();
}
-boost::shared_ptr<HttpRequest> HttpClientConnection::NewRequest(void)
+std::shared_ptr<HttpRequest> HttpClientConnection::NewRequest(void)
{
Reconnect();
- return boost::make_shared<HttpRequest>(m_Stream);
+ return std::make_shared<HttpRequest>(m_Stream);
}
-void HttpClientConnection::SubmitRequest(const boost::shared_ptr<HttpRequest>& request,
+void HttpClientConnection::SubmitRequest(const std::shared_ptr<HttpRequest>& request,
const HttpCompletionCallback& callback)
{
m_Requests.push_back(std::make_pair(request, callback));
void Disconnect(void);
- boost::shared_ptr<HttpRequest> NewRequest(void);
+ std::shared_ptr<HttpRequest> NewRequest(void);
typedef std::function<void(HttpRequest&, HttpResponse&)> HttpCompletionCallback;
- void SubmitRequest(const boost::shared_ptr<HttpRequest>& request, const HttpCompletionCallback& callback);
+ void SubmitRequest(const std::shared_ptr<HttpRequest>& request, const HttpCompletionCallback& callback);
private:
String m_Host;
String m_Port;
bool m_Tls;
Stream::Ptr m_Stream;
- std::deque<std::pair<boost::shared_ptr<HttpRequest>, HttpCompletionCallback> > m_Requests;
- boost::shared_ptr<HttpResponse> m_CurrentResponse;
+ std::deque<std::pair<std::shared_ptr<HttpRequest>, HttpCompletionCallback> > m_Requests;
+ std::shared_ptr<HttpResponse> m_CurrentResponse;
boost::mutex m_DataHandlerMutex;
StreamReadContext m_Context;
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/classification.hpp>
-#include <boost/smart_ptr/make_shared.hpp>
using namespace icinga;
} else if (m_State == HttpRequestBody) {
if (Headers->Get("transfer-encoding") == "chunked") {
if (!m_ChunkContext)
- m_ChunkContext = boost::make_shared<ChunkReadContext>(boost::ref(src));
+ m_ChunkContext = std::make_shared<ChunkReadContext>(boost::ref(src));
char *data;
size_t size;
private:
Stream::Ptr m_Stream;
- boost::shared_ptr<ChunkReadContext> m_ChunkContext;
+ std::shared_ptr<ChunkReadContext> m_ChunkContext;
HttpRequestState m_State;
FIFO::Ptr m_Body;
#include <boost/algorithm/string/classification.hpp>
#include "base/application.hpp"
#include "base/convert.hpp"
-#include <boost/smart_ptr/make_shared.hpp>
using namespace icinga;
} else if (m_State == HttpResponseBody) {
if (Headers->Get("transfer-encoding") == "chunked") {
if (!m_ChunkContext)
- m_ChunkContext = boost::make_shared<ChunkReadContext>(boost::ref(src));
+ m_ChunkContext = std::make_shared<ChunkReadContext>(boost::ref(src));
char *data;
size_t size;
private:
HttpResponseState m_State;
- boost::shared_ptr<ChunkReadContext> m_ChunkContext;
+ std::shared_ptr<ChunkReadContext> m_ChunkContext;
const HttpRequest& m_Request;
Stream::Ptr m_Stream;
FIFO::Ptr m_Body;
String certText = params->Get("cert_request");
- boost::shared_ptr<X509> cert;
+ std::shared_ptr<X509> cert;
Dictionary::Ptr result = new Dictionary();
cert = StringToCertificate(certText);
ApiListener::Ptr listener = ApiListener::GetInstance();
- boost::shared_ptr<X509> cacert = GetX509Certificate(listener->GetDefaultCaPath());
+ std::shared_ptr<X509> cacert = GetX509Certificate(listener->GetDefaultCaPath());
String cn = GetCertificateCN(cert);
}
}
- boost::shared_ptr<X509> newcert;
- boost::shared_ptr<EVP_PKEY> pubkey;
+ std::shared_ptr<X509> newcert;
+ std::shared_ptr<EVP_PKEY> pubkey;
X509_NAME *subject;
Dictionary::Ptr message;
String ticket;
}
}
- pubkey = boost::shared_ptr<EVP_PKEY>(X509_get_pubkey(cert.get()), EVP_PKEY_free);
+ pubkey = std::shared_ptr<EVP_PKEY>(X509_get_pubkey(cert.get()), EVP_PKEY_free);
subject = X509_get_subject_name(cert.get());
newcert = CreateCertIcingaCA(pubkey.get(), subject);
if (!listener)
return Empty;
- boost::shared_ptr<X509> oldCert = GetX509Certificate(listener->GetDefaultCertPath());
- boost::shared_ptr<X509> newCert = StringToCertificate(cert);
+ std::shared_ptr<X509> oldCert = GetX509Certificate(listener->GetDefaultCertPath());
+ std::shared_ptr<X509> newCert = StringToCertificate(cert);
String cn = GetCertificateCN(newCert);
<< "Received certificate update message for CN '" << cn << "'";
/* Check if this is a certificate update for a subordinate instance. */
- boost::shared_ptr<EVP_PKEY> oldKey = boost::shared_ptr<EVP_PKEY>(X509_get_pubkey(oldCert.get()), EVP_PKEY_free);
- boost::shared_ptr<EVP_PKEY> newKey = boost::shared_ptr<EVP_PKEY>(X509_get_pubkey(newCert.get()), EVP_PKEY_free);
+ std::shared_ptr<EVP_PKEY> oldKey = std::shared_ptr<EVP_PKEY>(X509_get_pubkey(oldCert.get()), EVP_PKEY_free);
+ std::shared_ptr<EVP_PKEY> newKey = std::shared_ptr<EVP_PKEY>(X509_get_pubkey(newCert.get()), EVP_PKEY_free);
if (X509_NAME_cmp(X509_get_subject_name(oldCert.get()), X509_get_subject_name(newCert.get())) != 0 ||
EVP_PKEY_cmp(oldKey.get(), newKey.get()) != 1) {
BIO_free(csrbio);
- boost::shared_ptr<EVP_PKEY> pubkey = boost::shared_ptr<EVP_PKEY>(X509_REQ_get_pubkey(req), EVP_PKEY_free);
- boost::shared_ptr<X509> cert = CreateCertIcingaCA(pubkey.get(), X509_REQ_get_subject_name(req));
+ std::shared_ptr<EVP_PKEY> pubkey = std::shared_ptr<EVP_PKEY>(X509_REQ_get_pubkey(req), EVP_PKEY_free);
+ std::shared_ptr<X509> cert = CreateCertIcingaCA(pubkey.get(), X509_REQ_get_subject_name(req));
X509_REQ_free(req);
return 0;
}
-boost::shared_ptr<X509> PkiUtility::FetchCert(const String& host, const String& port)
+std::shared_ptr<X509> PkiUtility::FetchCert(const String& host, const String& port)
{
TcpSocket::Ptr client = new TcpSocket();
<< "Cannot connect to host '" << host << "' on port '" << port << "'";
Log(LogDebug, "pki")
<< "Cannot connect to host '" << host << "' on port '" << port << "':\n" << DiagnosticInformation(ex);
- return boost::shared_ptr<X509>();
+ return std::shared_ptr<X509>();
}
- boost::shared_ptr<SSL_CTX> sslContext;
+ std::shared_ptr<SSL_CTX> sslContext;
try {
sslContext = MakeSSLContext();
<< "Cannot make SSL context.";
Log(LogDebug, "pki")
<< "Cannot make SSL context:\n" << DiagnosticInformation(ex);
- return boost::shared_ptr<X509>();
+ return std::shared_ptr<X509>();
}
TlsStream::Ptr stream = new TlsStream(client, host, RoleClient, sslContext);
return stream->GetPeerCertificate();
}
-int PkiUtility::WriteCert(const boost::shared_ptr<X509>& cert, const String& trustedfile)
+int PkiUtility::WriteCert(const std::shared_ptr<X509>& cert, const String& trustedfile)
{
std::ofstream fpcert;
fpcert.open(trustedfile.CStr());
}
int PkiUtility::RequestCertificate(const String& host, const String& port, const String& keyfile,
- const String& certfile, const String& cafile, const boost::shared_ptr<X509>& trustedCert, const String& ticket)
+ const String& certfile, const String& cafile, const std::shared_ptr<X509>& trustedCert, const String& ticket)
{
TcpSocket::Ptr client = new TcpSocket();
return 1;
}
- boost::shared_ptr<SSL_CTX> sslContext;
+ std::shared_ptr<SSL_CTX> sslContext;
try {
sslContext = MakeSSLContext(certfile, keyfile);
return 1;
}
- boost::shared_ptr<X509> peerCert = stream->GetPeerCertificate();
+ std::shared_ptr<X509> peerCert = stream->GetPeerCertificate();
if (X509_cmp(peerCert.get(), trustedCert.get())) {
Log(LogCritical, "cli", "Peer certificate does not match trusted certificate.");
return 0;
}
-String PkiUtility::GetCertificateInformation(const boost::shared_ptr<X509>& cert) {
+String PkiUtility::GetCertificateInformation(const std::shared_ptr<X509>& cert) {
BIO *out = BIO_new(BIO_s_mem());
String pre;
result->Set("cert_response", certResponseText);
}
- boost::shared_ptr<X509> certRequest = StringToCertificate(certRequestText);
+ std::shared_ptr<X509> certRequest = StringToCertificate(certRequestText);
/* XXX (requires OpenSSL >= 1.0.0)
time_t now;
static int NewCa(void);
static int NewCert(const String& cn, const String& keyfile, const String& csrfile, const String& certfile);
static int SignCsr(const String& csrfile, const String& certfile);
- static boost::shared_ptr<X509> FetchCert(const String& host, const String& port);
- static int WriteCert(const boost::shared_ptr<X509>& cert, const String& trustedfile);
+ static std::shared_ptr<X509> FetchCert(const String& host, const String& port);
+ static int WriteCert(const std::shared_ptr<X509>& cert, const String& trustedfile);
static int GenTicket(const String& cn, const String& salt, std::ostream& ticketfp);
static int RequestCertificate(const String& host, const String& port, const String& keyfile,
- const String& certfile, const String& cafile, const boost::shared_ptr<X509>& trustedcert,
+ const String& certfile, const String& cafile, const std::shared_ptr<X509>& trustedcert,
const String& ticket = String());
- static String GetCertificateInformation(const boost::shared_ptr<X509>& certificate);
+ static String GetCertificateInformation(const std::shared_ptr<X509>& certificate);
static Dictionary::Ptr GetCertificateRequests(void);
private:
boost::condition_variable cv;
boost::mutex mtx;
Dictionary::Ptr result;
- boost::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
+ std::shared_ptr<HttpRequest> req = m_Connection->NewRequest();
req->RequestMethod = "GET";
// Url() will call Utillity::UnescapeString() which will thrown an exception if it finds a lonely %