Revize 586f1573
Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)
static/certificate.html | ||
---|---|---|
226 | 226 |
<table class="table"> |
227 | 227 |
<thead class="thead-dark"> |
228 | 228 |
<tr> |
229 |
<th colspan="4" class="text-center">Manage certificate</th>
|
|
229 |
<th colspan="5" class="text-center">Manage certificate</th>
|
|
230 | 230 |
</tr> |
231 | 231 |
</thead> |
232 | 232 |
<tbody> |
... | ... | |
237 | 237 |
<td><button v-on:click="onRootDownload()" class="btn btn-primary btn-sm certificate-control" href="">Root</button></td> |
238 | 238 |
</tr> |
239 | 239 |
<tr class="d-flex"> |
240 |
<td style="width: 30%" class="font-weight-bold">Key download:</td> |
|
240 |
<td style="width: 30%" class="font-weight-bold">Key/Identity download:</td>
|
|
241 | 241 |
<td><button v-on:click="onPublicKeyDownload()" class="btn btn-success btn-sm certificate-control" href="">Public key</button></td> |
242 | 242 |
<td><button v-on:click="onPrivateKeyDownload()" class="btn btn-success btn-sm certificate-control" href="">Private key</button></td> |
243 |
<td> </td>
|
|
243 |
<td><button data-toggle="modal" data-target="#identityModal" class="btn btn-success btn-sm certificate-control" href="">PKCS #12</button></td>
|
|
244 | 244 |
</tr> |
245 | 245 |
<tr class="d-flex"> |
246 | 246 |
<td style="width: 30%" class="font-weight-bold">Actions:</td> |
... | ... | |
283 | 283 |
</div> |
284 | 284 |
</div> |
285 | 285 |
</div> |
286 |
<div id="identityModal" class="modal" tabindex="-1" role="dialog"> |
|
287 |
<div class="modal-dialog" role="document"> |
|
288 |
<div class="modal-content"> |
|
289 |
<div class="modal-header"> |
|
290 |
<h5 class="modal-title">Create identity</h5> |
|
291 |
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> |
|
292 |
<span aria-hidden="true">×</span> |
|
293 |
</button> |
|
294 |
</div> |
|
295 |
<div class="modal-body"> |
|
296 |
<p>Enter identity name and password:</p> |
|
297 |
<div class="form-group"> |
|
298 |
<label for="reasonSelect">Name: </label> |
|
299 |
<input v-model="identityName" type="text" class="form-control"> |
|
300 |
</div> |
|
301 |
<div class="form-group"> |
|
302 |
<label for="reasonSelect">Password: </label> |
|
303 |
<input v-model="identityPass" type="password" class="form-control"> |
|
304 |
</div> |
|
305 |
</div> |
|
306 |
<div class="modal-footer"> |
|
307 |
<button type="button" v-on:click="onIdentityDownload" class="btn btn-primary" data-dismiss="modal">Create</button> |
|
308 |
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> |
|
309 |
</div> |
|
310 |
</div> |
|
311 |
</div> |
|
312 |
</div> |
|
286 | 313 |
<div id="revokeModal" class="modal" tabindex="-1" role="dialog"> |
287 | 314 |
<div class="modal-dialog" role="document"> |
288 | 315 |
<div class="modal-content"> |
static/js/certificate.js | ||
---|---|---|
12 | 12 |
issuerLoaded: false, |
13 | 13 |
revocationReason: "unspecified", |
14 | 14 |
issuedCertificates: [], |
15 |
identityName: "", |
|
16 |
identityPass: "", |
|
15 | 17 |
certificate: { |
16 | 18 |
subject: { |
17 | 19 |
C: "", |
... | ... | |
112 | 114 |
onPrivateKeyDownload: async function () { |
113 | 115 |
await onPrivateKeyDownload(this.id); |
114 | 116 |
}, |
117 |
onIdentityDownload: async function() { |
|
118 |
this.errorMessage = ""; |
|
119 |
if (this.identityName === "") { |
|
120 |
this.errorMessage = "Identity name must not be empty! Please try again."; |
|
121 |
document.body.scrollTop = 0; |
|
122 |
document.documentElement.scrollTop = 0; |
|
123 |
return; |
|
124 |
} |
|
125 |
await onIdentityDownload(this.id, this.identityName, this.identityPass); |
|
126 |
}, |
|
115 | 127 |
onRevoke: async function () { |
116 | 128 |
document.body.scrollTop = 0; |
117 | 129 |
document.documentElement.scrollTop = 0; |
static/js/utilities.js | ||
---|---|---|
105 | 105 |
} catch (error) { |
106 | 106 |
console.log(error); |
107 | 107 |
} |
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* Download identity given by certificate id, name and password |
|
112 |
* @param id identifier of certificate to be used for creating the identity |
|
113 |
* @param name name of the resulting identity |
|
114 |
* @param passphrase password protecting the identity |
|
115 |
*/ |
|
116 |
async function onIdentityDownload(id, name, passphrase) { |
|
117 |
try { |
|
118 |
var identityData = { |
|
119 |
name: name, |
|
120 |
password: passphrase |
|
121 |
} |
|
122 |
const response = await axios.post(API_URL + "certificates/" + id + "/identity", identityData); |
|
123 |
if (response.data["success"]) { |
|
124 |
download(name + ".p12", response.data["data"]) |
|
125 |
} else |
|
126 |
console.log("Error occurred while downloading the identity") // TODO more action may be required |
|
127 |
} catch (error) { |
|
128 |
console.log(error); |
|
129 |
} |
|
108 | 130 |
} |
Také k dispozici: Unified diff
Re #8706 - Downloading PKCS#12 identity