/* Copyright (c) Dovecot authors, see top-level COPYING file */

#include "lib.h"

#include "iostream-ssl.h"
#include "iostream-ssl-test.h"

static const char *test_ca_cert =
	"-----BEGIN CERTIFICATE-----\n"
	"MIIF4TCCA8mgAwIBAgICEAAwDQYJKoZIhvcNAQELBQAwgYQxCzAJBgNVBAYTAk5M\n"
	"MRMwEQYDVQQIDApHZWxkZXJsYW5kMRIwEAYDVQQHDAlCYXJuZXZlbGQxGjAYBgNV\n"
	"BAoMEUNoaWNrZW4gQ29vcCBCLlYuMR4wHAYDVQQLDBVDZXJ0aWZpY2F0ZSBBdXRo\n"
	"b3JpdHkxEDAOBgNVBAMMB1Jvb3QgQ0EwIBcNMTgwMjA4MjEyODE2WhgPMjExODAx\n"
	"MTUyMTI4MTZaMHgxCzAJBgNVBAYTAk5MMRMwEQYDVQQIDApHZWxkZXJsYW5kMRow\n"
	"GAYDVQQKDBFDaGlja2VuIENvb3AgQi5WLjEeMBwGA1UECwwVQ2VydGlmaWNhdGUg\n"
	"QXV0aG9yaXR5MRgwFgYDVQQDDA9JbnRlcm1lZGlhdGUgQ0EwggIiMA0GCSqGSIb3\n"
	"DQEBAQUAA4ICDwAwggIKAoICAQDgwuwUQ387ALkBO2YAvLiOi0rhQMis+TY34tpN\n"
	"96Xx9Jaa8gdiAW9y3l8hGFm1+Ens5ZukwMysUoP7rrI5s0XOgCTChzrB4dEnbWHj\n"
	"2YUYUBVLTLqZ4PTbY6xyrjYHKol1govkU+wclmyeI+Os946U0HFubg+KuXGZ2oLM\n"
	"iYAmur/oxickEwJX932KhzQS4xdT5o38cVv470ot6eNEAiZcufP/gBSjAyUd8Wge\n"
	"bwpW64fE/0LyCXYZrK5LWG1dMPC8MpETb8uLAB33r6q3yLTcEWg79bes7SgNrQdx\n"
	"ncUXBoh8YSJvniZQ6OhwENPGTNhZWzgltDZHASyKXY2ojV70D8iiy/uB+owPSTla\n"
	"txnu7z8B4kVCBWhCUizk7upjZNA0aFutjEHyYLtxqbTon+iLYm7M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BfA5ZKqQDguNBafU1BUOmPEO\n"
	"eNb8S5cJDMR7zKeZJ9dHzf4j78sITigwxt8+Ee6VY92U/uTFkPKZNLpAr3OfDSdh\n"
	"z+M/zgztKqdrSKhr64g/3Dbbe+XqdeGe8MIx+P+QN+SrJNNaNZ1r\n"
	"-----END RSA PRIVATE KEY-----\n";

static const char *test_server_dh =
	"-----BEGIN DH PARAMETERS-----\n"
	"MIIBCAKCAQEA/muURoAR4sDHCMSibIwduxRDFA+rizt6TQC6OhNfZ6sOtX+mANdx\n"
	"otSZIca/q37dQs34ph+/9AHnL3li7I9aUC9XzThFyq7eoKrMs9VlDlA0z1gc+gMG\n"
	"FS+S4Dp4bjNmQ8lJz13+8CS6jKV2RVcqY5Qfjz4QYIk7bcF3PK8d/kJxnGtihhKh\n"
	"90Cu4ZiMqpcvkfKRxommk9HvN9ceeHn5Heey2TdAQ9ngF43Z+g++DPt7lYiedh/X\n"
	"N5SFUcR8ZRCzrccPhXIBUd9uZtgJTlxg2ZQ/WL0MKbJd+DeP/kUK+DPK+VDVUIwT\n"
	"UE2GG5y3YCQ4i2PEahXYpaJGk6tn2oMd2wIBAg==\n"
	"-----END DH PARAMETERS-----\n";

void ssl_iostream_test_settings_server(struct ssl_iostream_settings *test_set)
{
	i_zero(test_set);
	test_set->pool = null_pool;
	test_set->ca.content = test_ca_cert;
	test_set->cert.cert.content = test_server_cert;
	test_set->cert.key.content = test_server_key;
	test_set->dh.content = test_server_dh;
	test_set->skip_crl_check = TRUE;
}

void ssl_iostream_test_settings_client(struct ssl_iostream_settings *test_set)
{
	i_zero(test_set);
	test_set->pool = null_pool;
	test_set->ca.content = test_ca_cert;
	test_set->skip_crl_check = TRUE;
}
