Revize 780c6d9c
Přidáno uživatelem Jan Pašek před asi 4 roky(ů)
app.py | ||
---|---|---|
51 | 51 |
def get_cert_chain(id, certificate_controller: CertController): |
52 | 52 |
return certificate_controller.get_certificate_trust_chain_by_id(id) |
53 | 53 |
|
54 |
@app.route('/api/certificates/<id>/private_key', methods=["GET"])
|
|
54 |
@app.route('/api/certificates/<id>/privatekey', methods=["GET"]) |
|
55 | 55 |
def get_private_key_of_a_certificate(id, certificate_controller: CertController): |
56 | 56 |
return certificate_controller.get_private_key_of_a_certificate(id) |
57 | 57 |
|
58 |
@app.route('/api/certificates/<id>/public_key', methods=["GET"])
|
|
58 |
@app.route('/api/certificates/<id>/publickey', methods=["GET"]) |
|
59 | 59 |
def get_public_key_of_a_certificate(id, certificate_controller: CertController): |
60 | 60 |
return certificate_controller.get_public_key_of_a_certificate(id) |
61 | 61 |
|
static/js/certificate.js | ||
---|---|---|
2 | 2 |
var certificateDetailsApp = new Vue({ |
3 | 3 |
el: "#certificate-detailed-view-content", |
4 | 4 |
data: { |
5 |
id: null, |
|
5 | 6 |
certificate: { |
6 | 7 |
subject: { |
7 | 8 |
C: "", |
... | ... | |
36 | 37 |
}, |
37 | 38 |
methods: { |
38 | 39 |
onCertificateDownload: function () { |
39 |
|
|
40 |
onCertificateDownload(this.id); |
|
40 | 41 |
}, |
41 | 42 |
onRootDownload: function () { |
42 |
|
|
43 |
onCertificateRootDownload(this.id); |
|
43 | 44 |
}, |
44 | 45 |
onChainDownload: function () { |
45 |
|
|
46 |
onCertificateChainDownload(this.id); |
|
46 | 47 |
}, |
47 | 48 |
onPublicKeyDownload: function () { |
48 |
|
|
49 |
onPublicKeyDownload(this.id); |
|
49 | 50 |
}, |
50 | 51 |
onPrivateKeyDownload: function () { |
51 |
|
|
52 |
onPrivateKeyDownload(this.id); |
|
52 | 53 |
}, |
53 | 54 |
onRevoke: function () { |
54 | 55 |
|
... | ... | |
65 | 66 |
const urlParams = new URLSearchParams(params); |
66 | 67 |
if (urlParams.get("id") != null) { |
67 | 68 |
const id = urlParams.get("id"); |
69 |
certificateDetailsApp.id = id; |
|
68 | 70 |
axios.get(API_URL + "certificates/"+id+"/details") |
69 | 71 |
.then(function (response) { |
70 | 72 |
if (response.data["success"]) |
static/js/utilities.js | ||
---|---|---|
27 | 27 |
return local.toJSON().slice(0,10); |
28 | 28 |
}); |
29 | 29 |
|
30 |
// Get the certificate PEM data from the server and downloads it to users computer |
|
30 |
/** |
|
31 |
* Download certificate given by id |
|
32 |
* @param id identifier of certificate to be downloaded |
|
33 |
*/ |
|
31 | 34 |
function onCertificateDownload(id) { |
32 | 35 |
axios.get(API_URL + "certificates/" + id) |
33 | 36 |
.then(function (response) { |
... | ... | |
41 | 44 |
}); |
42 | 45 |
} |
43 | 46 |
|
44 |
// Get the certificate's chain of trust in PEM format from the server and downloads it to users computer |
|
47 |
/** |
|
48 |
* Download root of chain of trust excluding root of given certificate |
|
49 |
* @param id identifier of certificate whose chain shall be downloaded |
|
50 |
*/ |
|
45 | 51 |
function onCertificateChainDownload(id) { |
46 | 52 |
axios.get(API_URL + "certificates/" + id + "/chain") |
47 | 53 |
.then(function (response) { |
... | ... | |
56 | 62 |
}); |
57 | 63 |
} |
58 | 64 |
|
59 |
// Get the certificate's root CA as PEM data from the server and downloads it to users computer |
|
65 |
/** |
|
66 |
* Download root of chain of trust corresponding to the given certificate |
|
67 |
* @param id identifier of certificate whose root shall be downloaded |
|
68 |
*/ |
|
60 | 69 |
function onCertificateRootDownload(id) { |
61 | 70 |
axios.get(API_URL + "certificates/" + id + "/root") |
62 | 71 |
.then(function (response) { |
... | ... | |
69 | 78 |
.catch(function (error) { |
70 | 79 |
console.log(error); |
71 | 80 |
}); |
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* Download public key associated with the selected certificate |
|
85 |
* @param id identifier of certificate whose pub. key shall be downloaded |
|
86 |
*/ |
|
87 |
function onPublicKeyDownload(id) { |
|
88 |
axios.get(API_URL + "certificates/" + id + "/publickey") |
|
89 |
.then(function (response) { |
|
90 |
if (response.data["success"]) { |
|
91 |
download(id + "_public_key.pem", response.data["data"]) |
|
92 |
} else |
|
93 |
console.log("Error occurred while downloading the certificate's public key") // TODO more action may be required |
|
94 |
}) |
|
95 |
.catch(function (error) { |
|
96 |
console.log(error); |
|
97 |
}); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* Download public key associated with the selected certificate |
|
102 |
* @param id identifier of certificate whose pub. key shall be downloaded |
|
103 |
*/ |
|
104 |
function onPrivateKeyDownload(id) { |
|
105 |
axios.get(API_URL + "certificates/" + id + "/privatekey") |
|
106 |
.then(function (response) { |
|
107 |
if (response.data["success"]) { |
|
108 |
download(id + "_private_key.pem", response.data["data"]) |
|
109 |
} else |
|
110 |
console.log("Error occurred while downloading the certificate's private key") // TODO more action may be required |
|
111 |
}) |
|
112 |
.catch(function (error) { |
|
113 |
console.log(error); |
|
114 |
}); |
|
72 | 115 |
} |
Také k dispozici: Unified diff
Re #8583 - Downloading certificate keys