diff --git a/certidude/api/request.py b/certidude/api/request.py index a84b85e..9918851 100644 --- a/certidude/api/request.py +++ b/certidude/api/request.py @@ -33,6 +33,10 @@ class RequestListResource(object): body = req.stream.read(req.content_length) + # Normalize body, TODO: newlines + if not body.endswith("\n"): + body += "\n" + csr = Request(body) if not csr.common_name: diff --git a/certidude/static/css/style.css b/certidude/static/css/style.css index 4c9517a..85a3fb9 100644 --- a/certidude/static/css/style.css +++ b/certidude/static/css/style.css @@ -168,8 +168,8 @@ pre { .icon{ background-size: 24px; - background-position: 6px 2px; - padding-left: 32px; + background-position: 8px 5px; + padding-left: 36px; background-repeat: no-repeat; display: block; vertical-align: text-bottom; @@ -225,5 +225,7 @@ select { .icon.wireless { background-image: url("../img/iconmonstr-wireless-6.svg"); } .icon.password { background-image: url("../img/iconmonstr-lock-3.svg"); } +.icon.upload { background-image: url("../img/iconmonstr-upload-17.svg"); } + /* Make sure this is the last one */ .icon.busy{background-image:url("https://software.opensuse.org/assets/ajax-loader-ea46060b6c9f42822a3d58d075c83ea2.gif");} diff --git a/certidude/static/img/iconmonstr-upload-17.svg b/certidude/static/img/iconmonstr-upload-17.svg new file mode 100644 index 0000000..ad38fe6 --- /dev/null +++ b/certidude/static/img/iconmonstr-upload-17.svg @@ -0,0 +1 @@ + diff --git a/certidude/static/js/certidude.js b/certidude/static/js/certidude.js index 18ec357..e10f4d1 100644 --- a/certidude/static/js/certidude.js +++ b/certidude/static/js/certidude.js @@ -287,6 +287,33 @@ $(document).ready(function() { }); } + + if (session.request_submission_allowed) { + $("#request_submit").click(function() { + $(this).addClass("busy"); + $.ajax({ + method: "POST", + contentType: "application/pkcs10", + url: "/api/request/", + data: $("#request_body").val(), + dataType: "text", + complete: function(xhr, status) { + console.info("Request submitted successfully, server returned", xhr.status, status); + $("#request_submit").removeClass("busy"); + }, + success: function() { + // Clear textarea on success + $("#request_body").val(""); + }, + error: function(xhr, status, e) { + console.info("Submitting request failed with:", status, e); + alert(e); + } + }); + + }); + } + /** * Fetch leases associated with certificates */ diff --git a/certidude/static/views/authority.html b/certidude/static/views/authority.html index 1b1b5c6..df68903 100644 --- a/certidude/static/views/authority.html +++ b/certidude/static/views/authority.html @@ -126,13 +126,29 @@ forbidden

Pending requests

-

Submit a certificate signing request with Certidude:

-
certidude setup client {{session.common_name}}
+ {% if session.request_submission_allowed %} +

Generate private key and certificate signing request:

+ +
+openssl genrsa -out example.key 2048
+openssl req -new -sha256 -key example.key -out example.csr
+cat example.csr
+
+ +

Paste the contents here and click submit:

+ + + {% else %} +

Submit a certificate signing request with Certidude:

+
certidude setup client {{session.common_name}}
+ {% endif %}