Skip to content

Instantly share code, notes, and snippets.

@yasyf
Created November 30, 2016 00:49
Show Gist options
  • Save yasyf/c4454f1017f52c46baf4a38078bbe111 to your computer and use it in GitHub Desktop.
Save yasyf/c4454f1017f52c46baf4a38078bbe111 to your computer and use it in GitHub Desktop.
#!/usr/bin/php-cgi
<?php
session_name("mit_cert_auth");
session_set_cookie_params(0, '/', '.mit.edu');
session_start();
$server = $_SESSION['server'];
if(empty($server)){
die("Invalid Callback");
}
if (@isset($_SERVER['SSL_CLIENT_S_DN_CN'])) {
$time = time();
$tohash = "SecretKey123".$_SERVER['SSL_CLIENT_I_DN_O'].$time;
$hash = urlencode(sha1(md5($tohash)));
header("Location: http://$server/?hash=".$hash."&time=".$time."&name=".urlencode($_SERVER['SSL_CLIENT_S_DN_CN'])."&email=".urlencode($_SERVER['SSL_CLIENT_S_DN_Email']));
exit();
} else {
header("Location: http://$server/?err=nocert");
exit();
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment