diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/poco/NetSSL_OpenSSL/src/Utility.cpp | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/poco/NetSSL_OpenSSL/src/Utility.cpp')
-rw-r--r-- | contrib/libs/poco/NetSSL_OpenSSL/src/Utility.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/contrib/libs/poco/NetSSL_OpenSSL/src/Utility.cpp b/contrib/libs/poco/NetSSL_OpenSSL/src/Utility.cpp new file mode 100644 index 0000000000..5428b76996 --- /dev/null +++ b/contrib/libs/poco/NetSSL_OpenSSL/src/Utility.cpp @@ -0,0 +1,71 @@ +// +// Utility.cpp +// +// Library: NetSSL_OpenSSL +// Package: SSLCore +// Module: Utility +// +// Copyright (c) 2006-2009, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// SPDX-License-Identifier: BSL-1.0 +// + + +#include "Poco/Net/Utility.h" +#include "Poco/String.h" +#include "Poco/Util/OptionException.h" +#include <openssl/err.h> + + +namespace Poco { +namespace Net { + + +Context::VerificationMode Utility::convertVerificationMode(const std::string& vMode) +{ + std::string mode = Poco::toLower(vMode); + Context::VerificationMode verMode = Context::VERIFY_STRICT; + + if (mode == "none") + verMode = Context::VERIFY_NONE; + else if (mode == "relaxed") + verMode = Context::VERIFY_RELAXED; + else if (mode == "strict") + verMode = Context::VERIFY_STRICT; + else if (mode == "once") + verMode = Context::VERIFY_ONCE; + else + throw Poco::InvalidArgumentException("Invalid verification mode. Should be relaxed, strict or once but got", vMode); + + return verMode; +} + + +std::string Utility::convertCertificateError(long errCode) +{ + std::string errMsg(X509_verify_cert_error_string(errCode)); + return errMsg; +} + + +std::string Utility::getLastError() +{ + unsigned long errCode = ERR_get_error(); + if (errCode != 0) + { + char buffer[256]; + ERR_error_string_n(errCode, buffer, sizeof(buffer)); + return std::string(buffer); + } + else return "No error"; +} + + +void Utility::clearErrorStack() +{ + ERR_clear_error(); +} + + +} } // namespace Poco::Net |