http_listener with https url crashes on open

Dec 30, 2014 at 7:07 PM
Edited Dec 30, 2014 at 7:17 PM
I'm testing a very simple rest server, and it works just fine with the url: "http://localhost/test"
If I change this to: "https://localhost/test",
it crashes every time in
), with the following call stack:
KernelBase.dll!RaiseException()    Unknown
msvcr120d.dll!__ExceptionPtr::_RethrowException(void)   Unknown
msvcr120d.dll!__ExceptionPtrRethrow(void const *)   Unknown
rest.exe!std::exception_ptr::_RethrowException() Line 468   C++
rest.exe!std::rethrow_exception(std::exception_ptr _P) Line 534 C++
rest.exe!Concurrency::details::_ExceptionHolder::_RethrowUserException() Line 932   C++
rest.exe!Concurrency::details::_Task_impl_base::_Wait() Line 1779   C++
rest.exe!Concurrency::task<unsigned char>::wait() Line 3469 C++
rest.exe!Concurrency::task<void>::wait() Line 4376  C++
rest.exe!RestListener::RestListener(const web::uri & url) Line 6    C++
rest.exe!wmain(int argc, wchar_t * * argv) Line 10  C++
Anyone else seen this?
Dec 30, 2014 at 7:38 PM
Hi jp,

Based on the call stack it looks like you have a task with an unhandled exception from a task. Can you try wrapping your call to with a try catch for std::exception or http_exception and see what the error message/error code is? It should give you more information.

Here is more information about how PPL tasks work.

Dec 30, 2014 at 7:50 PM
Thanks for the prompt reply Steve, and great idea. I get this:

"Address 'https://localhost/test' is already in use" Which it isn't - I can change the URL, and add ports and get the same behavior. I've verified that nothing is on the local server at that address prior to running.
Dec 30, 2014 at 8:00 PM
Hi jp,

I assume the error code is ERROR_SHARING_VIOLATION, this means something else on your machine is probably using port. To test out can you try changing to some random high numbered port to guarantee there isn't something else using it? For example try https://localhost:34567/test Also please note on Windows to listen on port 80 is going to require administrative privileges.

Dec 30, 2014 at 9:38 PM
The error code is ERROR_ALREADY_EXISTS (183). Using a high port doesn't help.
Dec 30, 2014 at 11:38 PM
Undo. I was mangling the URL when specifying a higher port. It looks like this part works now. Thanks.
Dec 30, 2014 at 11:39 PM
Glad to hear you figured it out. My guess is that something like IIS is running on port 80.
Dec 30, 2014 at 11:48 PM
Edited Dec 30, 2014 at 11:50 PM
So, I noticed in the https Casablanca test code, that there were instructions to generate a self-signed cert. Are there instructions for what to do with that certificate in order to get http_listener with https working properly? A quick test with a Python rest client against my (now-running) rest server gets actively refused (socket error 10061). I'm assuming this is a cert issue, but maybe not?
Jan 2, 2015 at 8:32 PM
Hi jp,

I would have expected a different error code but I'm not sure. We don't have any options expose for certificates with the http_listener. I don't have any examples to share. Your best bet would be to look at the source code and find the correct location to add code to setup the certificate. All the source code for it is in http_server_httpsys.cpp. I think the function you want to retrieve the client certificate is HttpReceiveClientCertificate.