2 * Copyright 2016 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <folly/io/async/ssl/SSLErrors.h>
19 #include <gtest/gtest.h>
20 #include <openssl/err.h>
21 #include <openssl/x509.h>
23 using namespace testing;
24 using namespace folly;
26 TEST(SSLErrorsTest, TestMessage) {
27 ERR_load_crypto_strings();
30 X509_F_X509_STORE_ADD_CERT,
31 X509_R_CERT_ALREADY_IN_HASH_TABLE);
32 SSLException ex(0, err, 0, 0);
33 std::string expectedMsg =
34 "AsyncSocketException: error:0B07C065:"
35 "x509 certificate routines:X509_STORE_add_cert:"
36 "cert already in hash table, type = SSL error";
37 std::string actual = ex.what();
38 EXPECT_EQ(expectedMsg, actual);