/usr/include/boost/asio/ssl/old/basic_context.hpp is in libboost1.49-dev 1.49.0-3.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | //
// ssl/old/basic_context.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2005 Voipster / Indrek dot Juhani at voipster dot com
// Copyright (c) 2005-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_ASIO_SSL_OLD_BASIC_CONTEXT_HPP
#define BOOST_ASIO_SSL_OLD_BASIC_CONTEXT_HPP
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
# pragma once
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include <boost/asio/detail/config.hpp>
#include <string>
#include <boost/noncopyable.hpp>
#include <boost/asio/detail/throw_error.hpp>
#include <boost/asio/error.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ssl/context_base.hpp>
#include <boost/asio/detail/push_options.hpp>
namespace boost {
namespace asio {
namespace ssl {
namespace old {
/// SSL context.
template <typename Service>
class basic_context
: public context_base,
private boost::noncopyable
{
public:
/// The type of the service that will be used to provide context operations.
typedef Service service_type;
/// The native implementation type of the SSL context.
typedef typename service_type::impl_type impl_type;
/// Constructor.
basic_context(boost::asio::io_service& io_service, method m)
: service_(boost::asio::use_service<Service>(io_service)),
impl_(service_.null())
{
service_.create(impl_, m);
}
/// Destructor.
~basic_context()
{
service_.destroy(impl_);
}
/// Get the underlying implementation in the native type.
/**
* This function may be used to obtain the underlying implementation of the
* context. This is intended to allow access to context functionality that is
* not otherwise provided.
*/
impl_type impl()
{
return impl_;
}
/// Set options on the context.
/**
* This function may be used to configure the SSL options used by the context.
*
* @param o A bitmask of options. The available option values are defined in
* the context_base class. The options are bitwise-ored with any existing
* value for the options.
*
* @throws boost::system::system_error Thrown on failure.
*/
void set_options(options o)
{
boost::system::error_code ec;
service_.set_options(impl_, o, ec);
boost::asio::detail::throw_error(ec);
}
/// Set options on the context.
/**
* This function may be used to configure the SSL options used by the context.
*
* @param o A bitmask of options. The available option values are defined in
* the context_base class. The options are bitwise-ored with any existing
* value for the options.
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code set_options(options o,
boost::system::error_code& ec)
{
return service_.set_options(impl_, o, ec);
}
/// Set the peer verification mode.
/**
* This function may be used to configure the peer verification mode used by
* the context.
*
* @param v A bitmask of peer verification modes. The available verify_mode
* values are defined in the context_base class.
*
* @throws boost::system::system_error Thrown on failure.
*/
void set_verify_mode(verify_mode v)
{
boost::system::error_code ec;
service_.set_verify_mode(impl_, v, ec);
boost::asio::detail::throw_error(ec);
}
/// Set the peer verification mode.
/**
* This function may be used to configure the peer verification mode used by
* the context.
*
* @param v A bitmask of peer verification modes. The available verify_mode
* values are defined in the context_base class.
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code set_verify_mode(verify_mode v,
boost::system::error_code& ec)
{
return service_.set_verify_mode(impl_, v, ec);
}
/// Load a certification authority file for performing verification.
/**
* This function is used to load one or more trusted certification authorities
* from a file.
*
* @param filename The name of a file containing certification authority
* certificates in PEM format.
*
* @throws boost::system::system_error Thrown on failure.
*/
void load_verify_file(const std::string& filename)
{
boost::system::error_code ec;
service_.load_verify_file(impl_, filename, ec);
boost::asio::detail::throw_error(ec);
}
/// Load a certification authority file for performing verification.
/**
* This function is used to load the certificates for one or more trusted
* certification authorities from a file.
*
* @param filename The name of a file containing certification authority
* certificates in PEM format.
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code load_verify_file(const std::string& filename,
boost::system::error_code& ec)
{
return service_.load_verify_file(impl_, filename, ec);
}
/// Add a directory containing certificate authority files to be used for
/// performing verification.
/**
* This function is used to specify the name of a directory containing
* certification authority certificates. Each file in the directory must
* contain a single certificate. The files must be named using the subject
* name's hash and an extension of ".0".
*
* @param path The name of a directory containing the certificates.
*
* @throws boost::system::system_error Thrown on failure.
*/
void add_verify_path(const std::string& path)
{
boost::system::error_code ec;
service_.add_verify_path(impl_, path, ec);
boost::asio::detail::throw_error(ec);
}
/// Add a directory containing certificate authority files to be used for
/// performing verification.
/**
* This function is used to specify the name of a directory containing
* certification authority certificates. Each file in the directory must
* contain a single certificate. The files must be named using the subject
* name's hash and an extension of ".0".
*
* @param path The name of a directory containing the certificates.
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code add_verify_path(const std::string& path,
boost::system::error_code& ec)
{
return service_.add_verify_path(impl_, path, ec);
}
/// Use a certificate from a file.
/**
* This function is used to load a certificate into the context from a file.
*
* @param filename The name of the file containing the certificate.
*
* @param format The file format (ASN.1 or PEM).
*
* @throws boost::system::system_error Thrown on failure.
*/
void use_certificate_file(const std::string& filename, file_format format)
{
boost::system::error_code ec;
service_.use_certificate_file(impl_, filename, format, ec);
boost::asio::detail::throw_error(ec);
}
/// Use a certificate from a file.
/**
* This function is used to load a certificate into the context from a file.
*
* @param filename The name of the file containing the certificate.
*
* @param format The file format (ASN.1 or PEM).
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code use_certificate_file(const std::string& filename,
file_format format, boost::system::error_code& ec)
{
return service_.use_certificate_file(impl_, filename, format, ec);
}
/// Use a certificate chain from a file.
/**
* This function is used to load a certificate chain into the context from a
* file.
*
* @param filename The name of the file containing the certificate. The file
* must use the PEM format.
*
* @throws boost::system::system_error Thrown on failure.
*/
void use_certificate_chain_file(const std::string& filename)
{
boost::system::error_code ec;
service_.use_certificate_chain_file(impl_, filename, ec);
boost::asio::detail::throw_error(ec);
}
/// Use a certificate chain from a file.
/**
* This function is used to load a certificate chain into the context from a
* file.
*
* @param filename The name of the file containing the certificate. The file
* must use the PEM format.
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code use_certificate_chain_file(
const std::string& filename, boost::system::error_code& ec)
{
return service_.use_certificate_chain_file(impl_, filename, ec);
}
/// Use a private key from a file.
/**
* This function is used to load a private key into the context from a file.
*
* @param filename The name of the file containing the private key.
*
* @param format The file format (ASN.1 or PEM).
*
* @throws boost::system::system_error Thrown on failure.
*/
void use_private_key_file(const std::string& filename, file_format format)
{
boost::system::error_code ec;
service_.use_private_key_file(impl_, filename, format, ec);
boost::asio::detail::throw_error(ec);
}
/// Use a private key from a file.
/**
* This function is used to load a private key into the context from a file.
*
* @param filename The name of the file containing the private key.
*
* @param format The file format (ASN.1 or PEM).
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code use_private_key_file(const std::string& filename,
file_format format, boost::system::error_code& ec)
{
return service_.use_private_key_file(impl_, filename, format, ec);
}
/// Use an RSA private key from a file.
/**
* This function is used to load an RSA private key into the context from a
* file.
*
* @param filename The name of the file containing the RSA private key.
*
* @param format The file format (ASN.1 or PEM).
*
* @throws boost::system::system_error Thrown on failure.
*/
void use_rsa_private_key_file(const std::string& filename, file_format format)
{
boost::system::error_code ec;
service_.use_rsa_private_key_file(impl_, filename, format, ec);
boost::asio::detail::throw_error(ec);
}
/// Use an RSA private key from a file.
/**
* This function is used to load an RSA private key into the context from a
* file.
*
* @param filename The name of the file containing the RSA private key.
*
* @param format The file format (ASN.1 or PEM).
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code use_rsa_private_key_file(
const std::string& filename, file_format format,
boost::system::error_code& ec)
{
return service_.use_rsa_private_key_file(impl_, filename, format, ec);
}
/// Use the specified file to obtain the temporary Diffie-Hellman parameters.
/**
* This function is used to load Diffie-Hellman parameters into the context
* from a file.
*
* @param filename The name of the file containing the Diffie-Hellman
* parameters. The file must use the PEM format.
*
* @throws boost::system::system_error Thrown on failure.
*/
void use_tmp_dh_file(const std::string& filename)
{
boost::system::error_code ec;
service_.use_tmp_dh_file(impl_, filename, ec);
boost::asio::detail::throw_error(ec);
}
/// Use the specified file to obtain the temporary Diffie-Hellman parameters.
/**
* This function is used to load Diffie-Hellman parameters into the context
* from a file.
*
* @param filename The name of the file containing the Diffie-Hellman
* parameters. The file must use the PEM format.
*
* @param ec Set to indicate what error occurred, if any.
*/
boost::system::error_code use_tmp_dh_file(const std::string& filename,
boost::system::error_code& ec)
{
return service_.use_tmp_dh_file(impl_, filename, ec);
}
/// Set the password callback.
/**
* This function is used to specify a callback function to obtain password
* information about an encrypted key in PEM format.
*
* @param callback The function object to be used for obtaining the password.
* The function signature of the handler must be:
* @code std::string password_callback(
* std::size_t max_length, // The maximum size for a password.
* password_purpose purpose // Whether password is for reading or writing.
* ); @endcode
* The return value of the callback is a string containing the password.
*
* @throws boost::system::system_error Thrown on failure.
*/
template <typename PasswordCallback>
void set_password_callback(PasswordCallback callback)
{
boost::system::error_code ec;
service_.set_password_callback(impl_, callback, ec);
boost::asio::detail::throw_error(ec);
}
/// Set the password callback.
/**
* This function is used to specify a callback function to obtain password
* information about an encrypted key in PEM format.
*
* @param callback The function object to be used for obtaining the password.
* The function signature of the handler must be:
* @code std::string password_callback(
* std::size_t max_length, // The maximum size for a password.
* password_purpose purpose // Whether password is for reading or writing.
* ); @endcode
* The return value of the callback is a string containing the password.
*
* @param ec Set to indicate what error occurred, if any.
*/
template <typename PasswordCallback>
boost::system::error_code set_password_callback(PasswordCallback callback,
boost::system::error_code& ec)
{
return service_.set_password_callback(impl_, callback, ec);
}
private:
/// The backend service implementation.
service_type& service_;
/// The underlying native implementation.
impl_type impl_;
};
} // namespace old
} // namespace ssl
} // namespace asio
} // namespace boost
#include <boost/asio/detail/pop_options.hpp>
#endif // BOOST_ASIO_SSL_OLD_BASIC_CONTEXT_HPP
|