Revize b556270c
Přidáno uživatelem Jan Pašek před asi 4 roky(ů)
static/create_certificate.html | ||
---|---|---|
13 | 13 |
<div class="form-group"> |
14 | 14 |
<td><label for="CA">Certificate Authority:</label></td> |
15 | 15 |
<td class="pl-3"> |
16 |
<select name="CA" id="CA" class="form-control"> |
|
17 |
<option value="volvo">Self-Signed</option> |
|
18 |
<option value="#test-cert-id">Test</option> |
|
16 |
<select v-model="selectedCA" name="CA" id="CA" class="form-control"> |
|
17 |
<option value=null>Self-Signed</option> |
|
18 |
<option is="ca-select-item" |
|
19 |
v-for="ca in authorities" |
|
20 |
v-bind:ca="ca" |
|
21 |
v-bind:key="ca.id"></option> |
|
19 | 22 |
</select> |
20 | 23 |
</td> |
21 | 24 |
</div> |
... | ... | |
39 | 42 |
<div class="form-group"> |
40 | 43 |
<td><label for="issuer_CN">Common Name:</label></td> |
41 | 44 |
<td class="pl-3"> |
42 |
<input type="text" id="issuer_CN" name="issuer_CN" class="form-control" v-bind:value="selectedCA.CN" disabled> |
|
45 |
<input type="text" id="issuer_CN" name="issuer_CN" class="form-control" v-bind:value="selectedCAData.CN" disabled>
|
|
43 | 46 |
</td> |
44 | 47 |
</div> |
45 | 48 |
</tr> |
... | ... | |
47 | 50 |
<div class="form-group"> |
48 | 51 |
<td><label for="issuer_C">Country Code:</label></td> |
49 | 52 |
<td class="pl-3"> |
50 |
<input type="text" id="issuer_C" name="issuer_C" class="form-control" v-bind:value="selectedCA.C" disabled>
|
|
53 |
<input type="text" id="issuer_C" name="issuer_C" class="form-control" v-bind:value="selectedCAData.C" disabled>
|
|
51 | 54 |
</td> |
52 | 55 |
</div> |
53 | 56 |
</tr> |
... | ... | |
55 | 58 |
<div class="form-group"> |
56 | 59 |
<td><label for="issuer_L">Locality:</label></td> |
57 | 60 |
<td class="pl-3"> |
58 |
<input type="text" id="issuer_L" name="issuer_L" class="form-control" v-bind:value="selectedCA.L" disabled> |
|
61 |
<input type="text" id="issuer_L" name="issuer_L" class="form-control" v-bind:value="selectedCAData.L" disabled>
|
|
59 | 62 |
</td> |
60 | 63 |
</div> |
61 | 64 |
</tr> |
... | ... | |
63 | 66 |
<div class="form-group"> |
64 | 67 |
<td><label for="issuer_ST">Province/State:</label></td> |
65 | 68 |
<td class="pl-3"> |
66 |
<input type="text" id="issuer_ST" name="issuer_ST" class="form-control" v-bind:value="selectedCA.ST" disabled> |
|
69 |
<input type="text" id="issuer_ST" name="issuer_ST" class="form-control" v-bind:value="selectedCAData.ST" disabled>
|
|
67 | 70 |
</td> |
68 | 71 |
</div> |
69 | 72 |
</tr> |
... | ... | |
71 | 74 |
<div class="form-group"> |
72 | 75 |
<td><label for="issuer_O">Organization:</label></td> |
73 | 76 |
<td class="pl-3"> |
74 |
<input type="text" id="issuer_O" name="issuer_O" class="form-control" v-bind:value="selectedCA.O" disabled> |
|
77 |
<input type="text" id="issuer_O" name="issuer_O" class="form-control" v-bind:value="selectedCAData.O" disabled>
|
|
75 | 78 |
</td> |
76 | 79 |
</div> |
77 | 80 |
</tr> |
... | ... | |
79 | 82 |
<div class="form-group"> |
80 | 83 |
<td><label for="issuer_OU">Organization Unit:</label></td> |
81 | 84 |
<td class="pl-3"> |
82 |
<input type="text" id="issuer_OU" name="issuer_OU" class="form-control" v-bind:value="selectedCA.OU" disabled> |
|
85 |
<input type="text" id="issuer_OU" name="issuer_OU" class="form-control" v-bind:value="selectedCAData.OU" disabled>
|
|
83 | 86 |
</td> |
84 | 87 |
</div> |
85 | 88 |
</tr> |
... | ... | |
87 | 90 |
<div class="form-group"> |
88 | 91 |
<td><label for="issuer_emailAddress">Email:</label></td> |
89 | 92 |
<td class="pl-3"> |
90 |
<input type="email" id="issuer_emailAddress" name="issuer_emailAddress" class="form-control" v-bind:value="selectedCA.emailAddress" disabled> |
|
93 |
<input type="email" id="issuer_emailAddress" name="issuer_emailAddress" class="form-control" v-bind:value="selectedCAData.emailAddress" disabled>
|
|
91 | 94 |
</td> |
92 | 95 |
</div> |
93 | 96 |
</tr> |
static/js/components.js | ||
---|---|---|
1 | 1 |
Vue.component("certificate-item",{ |
2 |
props: ["certificate"], |
|
3 |
template: "<tr>"+ |
|
4 |
"<td class='align-middle'>{{ certificate.CN }}</td>"+ |
|
5 |
"<td class='align-middle'>{{ certificate.notBefore }}</td>"+ |
|
6 |
"<td class='align-middle'>{{ certificate.notAfter }}</td>"+ |
|
7 |
"<td class='align-middle'>" + |
|
8 |
" <div v-if='certificate.usage.CA'>CA</div>" + |
|
9 |
" <div v-if='certificate.usage.authentication'>authentication</div>" + |
|
10 |
" <div v-if='certificate.usage.digitalSignature'>digital signature</div>" + |
|
11 |
" <div v-if='certificate.usage.SSL'>SSL/TLS</div>" + |
|
12 |
"</td>"+ |
|
13 |
"<td class='align-middle'><button v-on:click='onCertificateDownload()'>Download certificate</button></td>"+ |
|
14 |
"<td class='align-middle'><button v-on:click='onCertificateChainDownload()'>Download chain of trust</button></td>"+ |
|
15 |
"<td class='align-middle'><button v-on:click='onCertificateRootDownload()'>Download chain root</button></td>"+ |
|
16 |
"</tr>", |
|
17 |
methods: { |
|
18 |
onCertificateDownload: function () { |
|
19 |
var id = this.certificate.id; |
|
20 |
axios.get(API_URL + "certificates/" + id) |
|
21 |
.then(function (response) { |
|
22 |
if(response.data["success"]) { |
|
23 |
download(id + ".crt", response.data["data"]) |
|
24 |
} |
|
25 |
else |
|
26 |
console.log("Error occurred while downloading the certificate") // TODO more action may be required |
|
27 |
}) |
|
28 |
.catch(function (error) { |
|
29 |
console.log(error); |
|
30 |
}); |
|
31 |
}, |
|
32 |
onCertificateChainDownload: function () { |
|
33 |
var id = this.certificate.id; |
|
34 |
axios.get(API_URL + "certificates/" + id + "/chain") |
|
35 |
.then(function (response) { |
|
36 |
if(response.data["success"]) { |
|
37 |
download(id + "_chain.crt", response.data["data"]) |
|
38 |
} |
|
39 |
else |
|
40 |
console.log("Error occurred while downloading the certificate's chain of trust") // TODO more action may be required |
|
41 |
}) |
|
42 |
.catch(function (error) { |
|
43 |
console.log(error); |
|
44 |
}); |
|
45 |
}, |
|
46 |
onCertificateRootDownload: function () { |
|
47 |
var id = this.certificate.id; |
|
48 |
axios.get(API_URL + "certificates/" + id + "/root") |
|
49 |
.then(function (response) { |
|
50 |
if(response.data["success"]) { |
|
51 |
download(id + "_root.crt", response.data["data"]) |
|
52 |
} |
|
53 |
else |
|
54 |
console.log("Error occurred while downloading the certificate's root CA") // TODO more action may be required |
|
55 |
}) |
|
56 |
.catch(function (error) { |
|
57 |
console.log(error); |
|
58 |
}); |
|
59 |
} |
|
2 |
props: ["certificate"], |
|
3 |
template: "<tr>"+ |
|
4 |
"<td class='align-middle'>{{ certificate.CN }}</td>"+ |
|
5 |
"<td class='align-middle'>{{ certificate.notBefore }}</td>"+ |
|
6 |
"<td class='align-middle'>{{ certificate.notAfter }}</td>"+ |
|
7 |
"<td class='align-middle'>" + |
|
8 |
" <div v-if='certificate.usage.CA'>CA</div>" + |
|
9 |
" <div v-if='certificate.usage.authentication'>authentication</div>" + |
|
10 |
" <div v-if='certificate.usage.digitalSignature'>digital signature</div>" + |
|
11 |
" <div v-if='certificate.usage.SSL'>SSL/TLS</div>" + |
|
12 |
"</td>"+ |
|
13 |
"<td class='align-middle'><button v-on:click='onCertificateDownload()'>Download certificate</button></td>"+ |
|
14 |
"<td class='align-middle'><button v-on:click='onCertificateChainDownload()'>Download chain of trust</button></td>"+ |
|
15 |
"<td class='align-middle'><button v-on:click='onCertificateRootDownload()'>Download chain root</button></td>"+ |
|
16 |
"</tr>", |
|
17 |
methods: { |
|
18 |
onCertificateDownload: function () { |
|
19 |
var id = this.certificate.id; |
|
20 |
axios.get(API_URL + "certificates/" + id) |
|
21 |
.then(function (response) { |
|
22 |
if(response.data["success"]) { |
|
23 |
download(id + ".crt", response.data["data"]) |
|
24 |
} |
|
25 |
else |
|
26 |
console.log("Error occurred while downloading the certificate") // TODO more action may be required |
|
27 |
}) |
|
28 |
.catch(function (error) { |
|
29 |
console.log(error); |
|
30 |
}); |
|
31 |
}, |
|
32 |
onCertificateChainDownload: function () { |
|
33 |
var id = this.certificate.id; |
|
34 |
axios.get(API_URL + "certificates/" + id + "/chain") |
|
35 |
.then(function (response) { |
|
36 |
if(response.data["success"]) { |
|
37 |
download(id + "_chain.crt", response.data["data"]) |
|
38 |
} |
|
39 |
else |
|
40 |
console.log("Error occurred while downloading the certificate's chain of trust") // TODO more action may be required |
|
41 |
}) |
|
42 |
.catch(function (error) { |
|
43 |
console.log(error); |
|
44 |
}); |
|
45 |
}, |
|
46 |
onCertificateRootDownload: function () { |
|
47 |
var id = this.certificate.id; |
|
48 |
axios.get(API_URL + "certificates/" + id + "/root") |
|
49 |
.then(function (response) { |
|
50 |
if(response.data["success"]) { |
|
51 |
download(id + "_root.crt", response.data["data"]) |
|
52 |
} |
|
53 |
else |
|
54 |
console.log("Error occurred while downloading the certificate's root CA") // TODO more action may be required |
|
55 |
}) |
|
56 |
.catch(function (error) { |
|
57 |
console.log(error); |
|
58 |
}); |
|
60 | 59 |
} |
61 |
}); |
|
60 |
} |
|
61 |
}); |
|
62 |
|
|
63 |
Vue.component("ca-select-item", { |
|
64 |
props: ["ca"], |
|
65 |
template: "<option v-bind:value='ca.id'>{{ ca.CN }}</option>" |
|
66 |
}); |
static/js/create_certificate.js | ||
---|---|---|
1 | 1 |
var createCertificateApp = new Vue({ |
2 | 2 |
el: "#create-certificate-content", |
3 | 3 |
data: { |
4 |
selectedCA: { |
|
4 |
authorities: [{id: 5, CN: "Test"}], |
|
5 |
selectedCA: null, |
|
6 |
selectedCAData: { |
|
5 | 7 |
CN: "", |
6 | 8 |
C: "", |
7 | 9 |
L: "", |
... | ... | |
10 | 12 |
OU: "", |
11 | 13 |
emailAddress: "" |
12 | 14 |
} |
15 |
}, |
|
16 |
watch: { |
|
17 |
selectedCA: function (val, oldVal) { |
|
18 |
if (val === "null" || val == null) { |
|
19 |
createCertificateApp.selectedCAData = { |
|
20 |
CN: "", |
|
21 |
C: "", |
|
22 |
L: "", |
|
23 |
ST: "", |
|
24 |
O: "", |
|
25 |
OU: "", |
|
26 |
emailAddress: "" |
|
27 |
}; |
|
28 |
} |
|
29 |
else { |
|
30 |
axios.get(API_URL + "certificates/" + val + "/details") |
|
31 |
.then(function (response) { |
|
32 |
if (response.data["success"]) { |
|
33 |
createCertificateApp.selectedCAData = response.data["data"]["subject"]; |
|
34 |
} |
|
35 |
else |
|
36 |
console.log("Error occurred while fetching CA details"); |
|
37 |
}) |
|
38 |
.catch(function (error) { |
|
39 |
console.log(error); |
|
40 |
}); |
|
41 |
} |
|
42 |
} |
|
43 |
} |
|
44 |
}); |
|
45 |
|
|
46 |
axios.get(API_URL+"certificates", { |
|
47 |
params: { |
|
48 |
filtering: { |
|
49 |
CA: true |
|
50 |
} |
|
51 |
} |
|
52 |
}) |
|
53 |
.then(function (response) { |
|
54 |
if (response.data["success"]) { |
|
55 |
createCertificateApp.authorities = response.data["data"]; |
|
13 | 56 |
} |
57 |
else |
|
58 |
console.log("Error occurred while fetching list of available certificate authorities"); |
|
59 |
}) |
|
60 |
.catch(function (error) { |
|
61 |
console.log(error); |
|
14 | 62 |
}); |
Také k dispozici: Unified diff
Re #8475 - Create certificate, available CA selection