aboutsummaryrefslogtreecommitdiff
path: root/actions/add.php
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-15 15:09:48 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-15 15:09:48 -0300
commit4fb376687dc1546f51e637cae1478582309f85f0 (patch)
tree8dd99abb6a221fd10bd86b00d5dd431ebcba4e0a /actions/add.php
downloadelgg-4fb376687dc1546f51e637cae1478582309f85f0.tar.gz
elgg-4fb376687dc1546f51e637cae1478582309f85f0.tar.bz2
Squashed 'mod/foafssl/' content from commit 3c1da1e
git-subtree-dir: mod/foafssl git-subtree-split: 3c1da1eaff8f61049b45ad99528f8f4e09ac7e62
Diffstat (limited to 'actions/add.php')
-rw-r--r--actions/add.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/actions/add.php b/actions/add.php
new file mode 100644
index 000000000..494229aad
--- /dev/null
+++ b/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");
+?>