Revize d74b9c59
Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)
static/create_certificate.html | ||
---|---|---|
185 | 185 |
<label class="form-check-label" for="isSSL_TLS">SSL/TLS</label><br> |
186 | 186 |
</td> |
187 | 187 |
</tr> |
188 |
<tr> |
|
189 |
<div class="form-group form-check"> |
|
190 |
<td><label class="form-check-label" for="specifyPasswordCheckbox" style="margin-top: 15px">Custom key:</label></td> |
|
191 |
<td class="pl-3"> |
|
192 |
<input type="checkbox" v-model="customKey" id="specifyPasswordCheckbox" name="specifyPassword" class="mb-2 form-check-input form-check"> |
|
193 |
</td> |
|
194 |
</div> |
|
195 |
</tr> |
|
196 |
<tr v-if="customKey"> |
|
197 |
<div class="form-group"> |
|
198 |
<td class="pl-5"><label for="key_password">Password:</label></td> |
|
199 |
<td class="pl-3"> |
|
200 |
<input type="text" v-model:value="key.password" id="key_password" name="key_password" class="form-control"> |
|
201 |
</td> |
|
202 |
</div> |
|
203 |
</tr> |
|
204 |
<tr v-if="customKey"> |
|
205 |
<div class="form-group"> |
|
206 |
<td class="pl-5"><label for="key_pem">Private key:</label></td> |
|
207 |
<td class="pl-3"> |
|
208 |
<input type="file" v-on:change="onKeyFileChange" id="key_pem" name="key_pem" class="form-control-file"> |
|
209 |
</td> |
|
210 |
</div> |
|
211 |
</tr> |
|
188 | 212 |
<tr> |
189 | 213 |
<td align="center"> |
190 | 214 |
<button class="btn btn-success mt-3 w-auto" v-on:click="onCreateCertificate()">Create certificate</button> |
static/js/create_certificate.js | ||
---|---|---|
6 | 6 |
notAfter: "", |
7 | 7 |
isSelfSigned: false, |
8 | 8 |
invalidCN: false, |
9 |
customKey: false, |
|
9 | 10 |
// available certificate authorities |
10 | 11 |
authorities: [], |
11 | 12 |
// data of the selected certificate authorities to be displayed in the form |
... | ... | |
38 | 39 |
}, |
39 | 40 |
CA: null |
40 | 41 |
}, |
42 |
key: { |
|
43 |
password: null, |
|
44 |
key_pem: null, |
|
45 |
}, |
|
41 | 46 |
errorMessage: "" |
42 | 47 |
}, |
43 | 48 |
// actions to be performed when the page is loaded |
... | ... | |
66 | 71 |
} |
67 | 72 |
}, |
68 | 73 |
methods: { |
74 |
onKeyFileChange: function (event) { |
|
75 |
var file = event.target.files[0]; |
|
76 |
var reader = new FileReader(); |
|
77 |
reader.readAsText(file, "UTF-8"); |
|
78 |
reader.onload = function (evt) { |
|
79 |
createCertificateApp.key.key_pem = evt.target.result; |
|
80 |
} |
|
81 |
reader.onerror = function (evt) { |
|
82 |
this.showError("Error occurred while reading custom private key file."); |
|
83 |
} |
|
84 |
|
|
85 |
}, |
|
69 | 86 |
showError: function (message) { |
70 | 87 |
document.body.scrollTop = 0; |
71 | 88 |
document.documentElement.scrollTop = 0; |
... | ... | |
84 | 101 |
this.invalidCN = true; |
85 | 102 |
return; |
86 | 103 |
} |
104 |
|
|
105 |
// populate optional key field in the request body |
|
106 |
if (this.key.password != null && this.key.password !== "") { |
|
107 |
this.certificateData.key.password = this.key.password; |
|
108 |
} |
|
109 |
if (this.key.key_pem != null) { |
|
110 |
this.certificateData.key.key_pem = this.key.key_pem; |
|
111 |
} |
|
112 |
|
|
87 | 113 |
this.certificateData.validityDays = parseInt(this.certificateData.validityDays); |
88 | 114 |
try { |
89 | 115 |
const response = await axios.post(API_URL + "certificates", this.certificateData); |
... | ... | |
95 | 121 |
createCertificateApp.showError(response.data["data"]); |
96 | 122 |
} |
97 | 123 |
} catch (error) { |
98 |
console.log(error);
|
|
124 |
createCertificateApp.showError(response.data["data"]);
|
|
99 | 125 |
} |
100 | 126 |
} |
101 | 127 |
}, |
Také k dispozici: Unified diff
Re #8706 - Providing custom private key