Skip to content

Commit ca9bf70

Browse files
committed
Merge remote-tracking branch 'origin/development' into development
2 parents cfcf828 + 5d7934b commit ca9bf70

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

CONTRIBUTORS.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Contributors should submit an update to this file with a commit in order to receive recognition. Thank you for your contributions.
2+
3+
4+
List of Contributors
5+
====================
6+
7+
Microsoft Corporation
8+
Brian Wengert (bwengert79)

Release/src/http/listener/http_listener.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ static void check_listener_uri(const http::uri &address)
3939
{
4040
// Somethings like proper URI schema are verified by the URI class.
4141
// We only need to check certain things specific to HTTP.
42+
43+
#ifdef _MS_WINDOWS
44+
//HTTP Server API includes SSL support
45+
if(address.scheme() != U("http") && address.scheme() != U("https"))
46+
{
47+
throw std::invalid_argument("URI scheme must be 'http' or 'https'");
48+
}
49+
#else
4250
if(address.scheme() == U("https"))
4351
{
4452
throw std::invalid_argument("Listeners using 'https' are not yet supported");
@@ -48,6 +56,7 @@ static void check_listener_uri(const http::uri &address)
4856
{
4957
throw std::invalid_argument("URI scheme must be 'http'");
5058
}
59+
#endif
5160

5261
if(address.host().empty())
5362
{

Release/tests/Functional/http/listener/http_listener_tests.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ namespace tests { namespace functional { namespace http { namespace listener {
2222
class uri_address
2323
{
2424
public:
25-
uri_address() : m_uri(U("http://localhost:34567/"))
25+
uri_address() :
26+
m_uri(U("http://localhost:34567/")),
27+
m_secure_uri(U("https://localhost:8443/"))
2628
{
2729
if (!s_dummy_listener)
2830
s_dummy_listener = std::make_shared<web::http::experimental::listener::http_listener>(U("http://localhost:30000/"));
@@ -33,6 +35,7 @@ class uri_address
3335

3436
static std::shared_ptr<web::http::experimental::listener::http_listener> s_dummy_listener;
3537
web::http::uri m_uri;
38+
web::http::uri m_secure_uri;
3639
};
3740

3841
}}}}

Release/tests/Functional/http/listener/requests_tests.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,31 @@ TEST_FIXTURE(uri_address, uri_encoding)
254254

255255
listener.close().wait();
256256
}
257+
258+
TEST_FIXTURE(uri_address, https_listener, "Ignore", "Manual")
259+
{
260+
// Requires a certificate for execution.
261+
// Here are instructions for creating a self signed cert. Full instructions can be located here:
262+
// http://blogs.msdn.com/b/haoxu/archive/2009/04/30/one-time-set-up-for-wwsapi-security-examples.aspx
263+
// From an elevated admin prompt:
264+
// 1. MakeCert.exe -ss Root -sr LocalMachine -n "CN=Fake-Test-CA" -cy authority -r -sk "CAKeyContainer"
265+
// 2. MakeCert.exe -ss My -sr LocalMachine -n "CN=localhost" -sky exchange -is Root -ir LocalMachine -in Fake-Test-CA -sk "ServerKeyContainer"
266+
// 3. Find corresponding SHA-1 hash with CertUtil.exe -store My localhost
267+
// 4. Netsh.exe http add sslcert ipport=0.0.0.0:8443 appid={00112233-4455-6677-8899-AABBCCDDEEFF} certhash=<40CharacterThumbprintWithNoSpaces>
268+
269+
http_listener listener(m_secure_uri);
270+
listener.open().wait();
271+
client::http_client client(m_secure_uri);
272+
273+
listener.support([&](http_request request)
274+
{
275+
request.reply(status_codes::OK);
276+
});
277+
278+
http_asserts::assert_response_equals(client.request(methods::GET, U("")).get(), status_codes::OK);
279+
280+
listener.close().wait();
281+
}
257282
}
258283

259284
}}}}

0 commit comments

Comments
 (0)