package examples.ssl;

import com.vtence.molecule.Application;
import com.vtence.molecule.Request;
import com.vtence.molecule.Response;
import com.vtence.molecule.WebServer;
import static com.vtence.molecule.support.ResourceLocator.locateOnClasspath;

import java.io.IOException;
import java.security.GeneralSecurityException;

public class SSLExample {

    public void run(WebServer server) throws IOException, GeneralSecurityException {
        // To generate a self-signed certificate using an 2048 bits RSA key pair, use the following command:
        // keytool -genkey -keyalg RSA -alias <key alias> -keystore <keystore file> -storepass <store password> -keysize 2048
        server.enableSSL(locateOnClasspath("ssl/keystore"), "password", "password");
        server.start(new Application() {
            public void handle(Request request, Response response) throws Exception {
                response.body("You are on a secure channel");
            }
        });
    }

    public static void main(String[] args) throws IOException, GeneralSecurityException {
        SSLExample example = new SSLExample();
        // Run the default web server on port 8443
        WebServer webServer = WebServer.create(8443);
        example.run(webServer);
        System.out.println("Access at " + webServer.uri());
    }
}

@@ -751,17 +751,16 @@
 ssword%22)
-;
 %0A       
@@ -760,22 +760,22 @@
         
-server
+      
 .start(n
@@ -793,16 +793,24 @@
 ion() %7B%0A
+        
         
@@ -903,16 +903,24 @@
         
+ 
+       
 response
@@ -969,18 +969,32 @@
         
-%7D%0A
+        %7D%0A      
         

Improve SSL example formatting