Skip to content

Instantly share code, notes, and snippets.

View humpydonkey's full-sized avatar

Asia humpydonkey

  • San Francisco, Bay Area
  • 00:16 (UTC -07:00)
  • LinkedIn in/yazhoucao
View GitHub Profile
@humpydonkey
humpydonkey / SSLPoke.java
Last active February 2, 2019 07:14 — forked from 4ndrej/SSLPoke.java
[SSL poke]Test of java SSL / keystore / cert setup. #java #ssl #test
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
public static void main(String[] args) {
@humpydonkey
humpydonkey / EnforceHttps.scala
Last active February 2, 2019 07:18 — forked from guillaumebort/gist:8314512
[Enforce HTTPS (Play!)]Force HTTPS decorator for Play framework #scala #play #ssl #web
def forceHttps(handler: Handler, request: RequestHeader): Handler = {
(isHTTPSRequired, isRequestSecure(request), request.method, request.uri) match {
// HTTPS is supported but not required for the API
case (_, _, _, uri) if uri.startsWith("/api") => handler
// HTTPS is required here, redirect GET requests
case (true, false, "GET", uri) => Action(Results.Redirect(s"https://${request.domain}${request.uri}"))
// HTTPS is required but we can't redirect