Enable SSL in GoAhead Web Server

Source: Internet
Author: User

GoAhead Web Server comes with internal SSL support. it's disabled by default, and I haven't seen a tutorial around this topic on the web. so here is the my adventure of enabling it.

Difficulties with goahead
According to the goahead's feature page, SSL is fully supported. but it's not so convienent to enable it. the downloaded source package doesn' t include the source code of the SSL library that it depends It. even the distribution package (header file and library file) isn' t there.
If we trun the macro webs_ssl_support definition on, what we get eventually is compilcation error. You may see the error of Type SSL isn' t defined.
Then we can see there is a mocana project file, so we guess go ahead is using mocana library. And now problem comes, mocana is a comerical product and it's not freely available.

Use OpenSSL instead
Luckily, we found there was a macro named OpenSSL. It's a symbol of OpenSSL can be an alternative option here.
Looking deeply inside the code, we can see that goahead provides a abstract layer above the underlying SSL library. So that we can change the implementaion easily. See? It's a typical usage of adapter design pattern.
We downloaded the OpenSSL source, compile a Linux version binary set. the OpenSSL is a powerful SSL tool set. in addition to the SSL library itself, it also contains several utility tools. within those tools, OpenSSL is a useful terminal tool. it can act as a SSL server, ssl client, and certificate file generator.
What's specifically useful is we can generate and sign certificate file with it and use them to test our server. This page tells how to generate and sign certificates.
In goahead's code, it uses three certificate files.
Privkey. pem: the private key
Cacert. pem: The certificate
Server. pem: a combination of private key and cacert. the first part of its content is privkey. PEM and the second part is cacert. pem.

Having got those files, we changed the makefile to define webs_ssl_support and OpenSSL macro to enable SSL. Compiled again and run.

How to visit
The GoAhead Web server listens on a differnt port for incoming secure connection. the port is defined as ssl_port macro N in websssl. c with default value 433. to test, open the browser and visit https: // address: ssl_port.
Since we used a self signed certificates, the Firefox won't allow access to it. we have to add our site to Firefox exception list from "tools-advanced-encryption-view certificates-add exception ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.