Projekt

Obecné

Profil

« Předchozí | Další » 

Revize dd7fb7a3

Přidáno uživatelem Jan Pašek před téměř 4 roky(ů)

Re #8706 - Rebased to current master

Zobrazit rozdíly:

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
                // create a deep copy of the certificate dataa
......
106 132
                    createCertificateApp.showError(response.data["data"]);
107 133
                }
108 134
            } catch (error) {
109
                this.showError("An error occurred while creating a certificate. For more details, see console.")
135
                createCertificateApp.showError(response.data["data"]);
110 136
                console.log(error);
111 137
            }
112 138
        }

Také k dispozici: Unified diff