diff options
Diffstat (limited to 'mod/foafssl/actions/add.php')
-rw-r--r-- | mod/foafssl/actions/add.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/mod/foafssl/actions/add.php b/mod/foafssl/actions/add.php new file mode 100644 index 000000000..494229aad --- /dev/null +++ b/mod/foafssl/actions/add.php @@ -0,0 +1,43 @@ +<?php +global $CONFIG; +$user = get_loggedin_user(); +$name = get_input('name'); +$webid = get_input('webid'); +$modulus = get_input('modulus'); +$exponent = get_input('exponent'); + +error_log($name); +error_log($webid); +error_log($modulus); +error_log($exponent); + +if (isset($_FILES['cert_file'])) { + $cert = get_uploaded_file('cert_file'); + $res = openssl_x509_read($cert); + $cert_data = openssl_x509_parse($cert); + $pubKey = openssl_pkey_get_public($res); + $keyData = openssl_pkey_get_details($pubKey); + $webid = $cert_data["extensions"]["subjectAltName"]; + + //Remove certificate armour + $unpacked_n = unpack("H*",$keyData['rsa']['n']); + $modulus = strtoupper($unpacked_n[1]); + + $unpacked_e = unpack("H*",$keyData['rsa']['e']); + $exponent = hexdec($unpacked_e[1]); + $name = $cert_data["subject"]["CN"]; + error_log("load file"); + error_log("webid:".$webid); + error_log("exponent".$exponent); + error_log("mod".$modulus); +} + +if ($modulus && $exponent && $user && $webid) { + $key = elgg_foafssl_createkey($modulus, $exponent, $user, $webid, $name); + system_message(elgg_echo("foafssl:addkey")); +} +else { + register_error(elgg_echo("foafssl:cantadd")); +} +forward($CONFIG->wwwroot."pg/foafssl/manage"); +?> |