kernelsauce / turbo

Turbo is a framework built for LuaJIT 2 to simplify the task of building fast and scalable network applications. It uses a event-driven, non-blocking, no thread design to deliver excellent performance and minimal footprint to high-load applications while also providing excellent support for embedded uses.
http://turbo.readthedocs.io/
Apache License 2.0
525 stars 84 forks source link

How to start a HTTPS server? #341

Closed reddevilM closed 5 years ago

reddevilM commented 5 years ago

I am trying to create http server using the examples. However I am unable to do so. I modified the json.lua example. Does turbo support https server functionality?

[root@ecmngr117 examples]# cat json.lua --- Turbo.lua JSON output example

-- Copyright 2013 John Abrahamsen

-- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at

-- http://www.apache.org/licenses/LICENSE-2.0

-- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License.

TURBO_SSL = true local turbo = require "turbo"

local MyJSONHandler = class("MyJSONHandler", turbo.web.RequestHandler) function MyJSONHandler:get() self:write({ "one", "two", "three", "easy", "json" }) end

turbo.web.Application:new({ {"https^/json/test$", MyJSONHandler, ssl_options = { key_file = "./sslkeys/serverPrivateKey.pem", cert_file = "./sslkeys/cachain.crt" } } }):listen(8888)

turbo.ioloop.instance():start()

reddevilM commented 5 years ago

Issue resolved. Mistake in the certificate file