Viewing File: /usr/local/cpanel/base/frontend/jupiter/ssl/crts.html.tt

[%
USE CPIcons;
USE CPList;
USE SSL;
USE JSON;
USE Geo;
USE CPScalar;

# CONSTANTS
SET SHOW_HELPER_LINKS_RECORD_COUNT = 10;

SET MINIMUM_MODULUS_LENGTH = SSL.DEFAULT_KEY_SIZE;

SET CPANEL.CPVAR.dprefix = '../';

SET SYSTEM_DEFAULT_KEY_TYPE = SSL.key_types_and_labels().0;
SET DEFAULT_NEW_KEY_TYPE = SSL.default_key_type() || SYSTEM_DEFAULT_KEY_TYPE.type;
SET DEFAULT_NEW_KEY_LABEL = "";

FOREACH key_type = SSL.key_types_and_labels();
    IF DEFAULT_NEW_KEY_TYPE == key_type.type;
        DEFAULT_NEW_KEY_LABEL = key_type.label;
    END;
END;

# Fetch the certificates for this user
SET list_certs = execute('SSL', 'list_certs', {
        'api.sort_column' => 'subject.commonName',
    } );

SET expiration_times = list_certs.data.ofeach('not_after');

IF expiration_times && expiration_times.size() > 0;
    FOR exp_time = expiration_times;
        expiration_times.${loop.index} = exp_time + 1;
    END;

    SET expiration_date = locale.get_lookup_hash_of_multi_epoch_datetime( expiration_times, 'date_format_short' );
    SET expiration_datetime = locale.get_lookup_hash_of_multi_epoch_datetime( expiration_times, 'datetime_format_short' );
ELSE;
    SET expiration_date = 0;
    SET expiration_datetime = 0;
END;

# Fetch the keys for this user.
SET list_keys = execute('SSL', 'list_keys', {
        'api.sort_column' => 'friendly_name',
    } );
SET has_certs_error = !list_certs.status;
SET has_certs_data = !has_certs_error && list_certs.data.size;

SET list_count = list_certs.data ? list_certs.data.size() : 0;

#Domains
SET list_mail_domains = execute('WebVhosts','list_domains', {
    'api.sort_column' => 'domain',
});

%]


[% js_code = PROCESS js_block %]
[% WRAPPER '_assets/master.html.tt'
    app_key = 'ssl_tls'
    include_legacy_scripts = 1
    include_cjt = 1
    page_js = js_code
    embed_stylesheets = ["css/ssl.css"]
    page_stylesheets = ["css2-min/ssl/crts.css"]
-%]
[% PROCESS _assets/_ajaxapp_header.html.tt -%]

<div class="body-content">

    <div class="section">
        [% IF list_count > SHOW_HELPER_LINKS_RECORD_COUNT %]
        <a id="top"></a>
        <div class="related related-top">
            <a id="upload-link" href="javascript:void(0)" class="dependent-action">[% locale.maketext('Upload a Certificate.') %]</a>
            <a id="generate-link" href="javascript:void(0)" class="dependent-action">[% locale.maketext('Generate a self-signed certificate.') %]</a>
        </div>
        [% END %]

        <h2 id="hdrCertificates">
            [% locale.maketext('SSL Certificates') %]
        </h2>


        <p id="descSelfsigned" class="description">[% locale.maketext('You can use a self-signed certificate or a trusted certificate from an SSL Certificate Authority. If you plan to use a self-signed certificate for one of your sites, you can generate it below. To use a trusted certificate, upload or provide the certificate below, after you have received the SSL certificate from your trusted provider.') %]</p>

        <h2 id="hdrOnserver">[% locale.maketext("Certificates on Server") %]</h2>
        <table class="sortable table table-striped" id="ssltable">
            <thead>
                <tr>
                    <th scope="col">[% locale.maketext('Domains') %]</th>
                    <th scope="col">[% locale.maketext('Issuer') %]</th>
                    <th scope="col">[% locale.maketext('Expiration ([_1])','UTC') %]</th>
                    <th scope="col">[% locale.maketext('Key Type') %]</th>
                    <th scope="col">[% locale.maketext('Description') %]</th>
                    <th class="sorttable_nosort" scope="col">[% locale.maketext("Actions") %]</th>
                </tr>
            </thead>
            <tbody>
            [% IF list_certs.data.size %]
                [% SET warn_icon = CPIcons.get_common_icon_markup("warning", 16); -%]
                [% SET error_icon = CPIcons.get_common_icon_markup("error", 16); -%]

                [% FOREACH cert = list_certs.data;
                    SET modulus_length = cert.modulus_length;
                    SET modulus_class = '';
                    SET modulus_error = 0;
                    IF key.key_algorithm == 'rsaEncryption' && modulus_length < MINIMUM_MODULUS_LENGTH;
                        modulus_class = 'modulus-critical';
                        modulus_error = 1;
                    END;

                    IF cert.is_self_signed;
                        SET issuer = locale.maketext('[comment]- Self Signed -[comment,The decorating dashes are meant to visually distinguish this label from a certificate authority name.]');
                    ELSE;
                        SET issuer = cert.${'issuer.organizationName'};
                    END;

                    SET inactive_reason = '';
                    IF !cert.domain_is_configured;
                        inactive_reason = locale.maketext('This certificate does not match any of your account’s domains.');
                    END;

                    SET cert_expiration = cert.not_after + 1;
                %]
                <tr class="[% modulus_class %]">
                    <td class="subject-column column"><div title="[% locale.list_and(cert.domains) FILTER html %]">[% cert.domains.join("\n").html().breakOn('\.').replace("\n",'<br>') %]</div></td>
                    <td class="issuer-column column"><div class="[%IF cert.is_self_signed %] self-signed[% END %]" title="[% issuer FILTER html %]">[% issuer.html().breakOn('\.') %]</div></td>
                    <td class="expires-column column" title="[% expiration_datetime.${cert_expiration} %]"><div>[% expiration_date.${cert_expiration} %]</div></td>
                    <td class="keytype-column column"><span>[% SSL.translate_key_parts_to_label(cert) %]</span>
                        [% IF modulus_error %]
                            [% error_icon %]
                        [% END %]
                    </td>
                    <td class="description-column column"><div title="[% cert.friendly_name FILTER html %]">[% cert.friendly_name.html().breakOn('\.') %]</div></td>
                    <td class="actions-column">
                        <a id="show-cert-[% loop.index %]" class="btn btn-link" href="viewcrt.html?id=[% cert.id FILTER uri %]">
                            <span class="glyphicon glyphicon-pencil"></span>
                            [% locale.maketext('Edit') %]</a>
                        <a id="del-cert-[% loop.index %]" class="btn btn-link" href="deletecrtconfirm.html?id=[% cert.id FILTER uri %]">
                            <span class="glyphicon glyphicon-trash"></span>
                            [% locale.maketext("Delete") %]</a>
                            [% IF inactive_reason -%]
                                <span class="non-domain-matching-cert inactive-link" title="[% inactive_reason %]">[% locale.maketext("Install") -%]</span>
                            [% ELSE -%]
                                <a class="btn btn-link" href="install.html?id=[% cert.id FILTER uri %]#installer">
                                    <span class="glyphicon glyphicon-download"></span>
                                    [% locale.maketext("Install") %]</a>
                            [% END -%]
                    </td>
                </tr>
                [% END %]
            [% ELSE %]
                <tr>
                    <td id="nocertsErrorMsg" colspan="6" class="errors">[% locale.maketext("There are no certificates on the server.") %]</td>
                </tr>
            [% END %]
            </tbody>
        </table>
    </div>

    <div class="section">
        [% IF list_count > SHOW_HELPER_LINKS_RECORD_COUNT %]
        <a id="upload">&nbsp;</a>
        <div class="related">
            <a id="top-link" href="javascript:void(0)" class="dependent-action">[% locale.maketext('List Certificates') %]</a>
            <a id="generate2-link" href="javascript:void(0)" class="dependent-action">[% locale.maketext('Generate a self-signed certificate.') %]</a>
        </div>
        [% END %]

        <h2>[% locale.maketext("Upload a New Certificate") %]</h2>
        <p id="descUpload" class="description">
            [% locale.maketext("Use this form to upload a certificate provided by a third-party Certificate Authority. You may either paste the body of the certificate or upload it from a “[_1]” file.", ".crt") %]
        </p>

        <form action="uploadcrt.html" name="upload" id="paste" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label id="lblCrt" for="crt">[% locale.maketext('Paste the certificate into the following text box:') %]</label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <textarea class="form-control textarea-base64 paste" name="crt" id="crt" dir="ltr" rows="15" title="[% locale.maketext('The certificate should include the lines that contain BEGIN and END.') %]"></textarea>
                        <div id="cert_parse" class="textarea-parse"></div>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label id="lblUp1fname" for="up1-fname">[% locale.maketext('Description') %]</label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <textarea id="up1-fname" type="text" class="form-control" name="friendly_name" rows="2"></textarea>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <input id="save-certificate" type="submit" class="btn btn-primary" value="[% locale.maketext('Save Certificate') %]" />
            </div>
        </form>

        <div class="connector">
            [% locale.maketext('or[comment,this is meant to be a horizontal separator of 2 things stacked vertically]') %]
        </div>

        <form action="uploadcrt.html" name="upload" id="upload" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label id="lblCrtfile" for="crtfile">[% locale.maketext('Choose a certificate file ([_1]).', '*.crt') %]</label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <input type="file" name="crtfile" id="crtfile" title="[% locale.maketext("The certificate files usually have the “[_1]” extension.", '.crt') %]" />
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label id="lblUp2fname" for="up2-fname">[% locale.maketext('Description') %]</label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <textarea id="up2-fname" type="text" class="form-control" name="friendly_name" rows="2"></textarea>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <input id="upload-certificate" type="submit" class="btn btn-primary" value="[% locale.maketext('Upload Certificate') %]" />
            </div>
        </form>
    </div>

    <div class="section">
        [% IF list_count > SHOW_HELPER_LINKS_RECORD_COUNT %]
        <a id="generate" name="generate">&nbsp;</a>
        <div class="related">
            <a id="top2-link" href="javascript:void(0)" class="dependent-action">[% locale.maketext('List Certificates') %]</a>
            <a id="upload2-link" href="javascript:void(0)" class="dependent-action">[% locale.maketext('Upload a Certificate.') %]</a>
        </div>
        [% END %]

        <h2 id="hdrNewcert">[% locale.maketext("Generate a New Certificate") %]</h2>
        <p id="descNewcert" class="description">
            [% locale.maketext('Use this form to generate a new, self-signed certificate for your domain. Typically, self-signed certificates are temporarily used until you receive a trusted SSL certificate from your SSL certificate authority.') %]
        </p>
        <div id="cjt_pagenotice_container" class="cjt-pagenotice-container cjt-notice-container"></div>
        <form action="gencrt.html" method="post" name="mainform" id="mainform" class="simple">
            <div class="form-group">
                <label id="lblKeyid" for="key_id"><span>[% locale.maketext('Key') %]</span><span class="extra">*</span></label>
                <input type="hidden" value="[% DEFAULT_NEW_KEY_TYPE %]" name="default_key_type" />
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <select name="key_id" id="key_id" class="form-control">
                            <option value="">[% locale.maketext('Generate a new “[_1]” key.', DEFAULT_NEW_KEY_LABEL) %]</option>
                            [% FOR key = list_keys.data -%]
                                <option value="[% key.id.html() %]">[% key.friendly_name.html() %]</option>
                            [% END -%]
                        </select>
                    </div>
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        [% IF list_keys.data.size -%]
                        <a id="view-key" class="dependent-action" href="javascript:void(0)" title="[% locale.maketext('This option allows you to view the certificate and edit the certificate’s description.') %]">[% locale.maketext('View [output,amp] Edit') %]</a>
                        [% END -%]
                        <div id="key_id_error" ></div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label id="lblDomains" for="domains"><span>[% locale.maketext('Domains') %]</span><span class="extra">*</span></label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <textarea name="domains" id="domains" rows="3" cols="15" class="form-control"></textarea>
                        <div class="help-block">[% locale.maketext('Provide the [output,acronym,FQDN,Fully Qualified Domain Name]s that you are trying to secure, one per line. You may also use wildcard domains by adding an asterisk in a domain name in the form: [output,em,_1].','*.example.com') %] ([% locale.maketext('Certificates with multiple domains are sometimes called “[output,acronym,UCC,Unified Communications Certificate]s” or “[output,acronym,SAN,subjectAltName] certificates”.') %])</div>
                    </div>
                    <div id="domains_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6"></div>
                </div>
            </div>
            <div class="form-group">
                <label id="lblCity" for="city"><span>[% locale.maketext("City") %]</span><span class="extra">*</span></label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <input id="city" type="text" class="form-control" name="city" class="validator_position_right" />
                        <div class="help-block">[% locale.maketext('Provide the complete name for the city or locality. Do not use abbreviations.') %]</div>
                    </div>
                    <div id="city_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6"></div>
                </div>
            </div>
            <div class="form-group">
                <label id="lblState" for="state"><span>[% locale.maketext("State") %]</span><span class="extra">*</span></label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <input id="state" type="text" class="form-control" name="state" class="validator_position_right" />
                        <div class="help-block">[% locale.maketext('Provide the complete name for the state or province. Do not use abbreviations.') %]</div>
                    </div>
                    <div id="state_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6"></div>
                </div>
            </div>
            <div class="form-group">
                <label id="lblCountry" for="country"><span>[% locale.maketext("Country") %]</span><span class="extra">*</span></label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <select id="country" name="country" class="form-control">
                            <option value="">[% locale.maketext('Choose a country.') %]</option>
                            [% SET locales_obj = locale.get_locales_obj() -%]
                            [% FOR country_code = Geo.COUNTRY_CODES -%]
                                [% SET country_name = locales_obj.get_territory_from_code(country_code) -%]
                                <option value="[% country_code | upper %]">
                                    [% country_code | upper %]
                                    [% country_name ? " ($country_name)" : '' %]
                                </option>
                            [% END -%]
                        </select>
                        <span class="help-block">[% locale.maketext("Choose the country of origin for the certificate’s company.") %]</span>
                    </div>
                    <div id="country_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label id="lblCompany" for="company"><span>[% locale.maketext("Company") %]</span><span class="extra">*</span></label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <input id="company" type="text" class="form-control" name="company" class="validator_position_right" />
                        <div class="help-block">[% locale.maketext('Provide the legally-registered name for your business. If your company name includes symbols other than a period or comma, check with your certificate authority to confirm that they are acceptable.') %]</div>
                    </div>
                    <div id="company_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label id="lblCompanyDivision" for="companydivision">[% locale.maketext("Company Division") %]</label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <input id="companydivision" type="text" class="form-control" name="companydivision" class="validator_position_right" />
                        <div class="help-block">[% locale.maketext('Provide the name of the division or group within the above company. If the division includes symbols other than a period or comma, check with your certificate authority to confirm that they are acceptable.') %]</div>
                    </div>
                    <div id="companydivision_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    </div>
                </div>
            </div>
            <div class="form-group">
                 <label id="lblEmail" for="email">[% locale.maketext("Email") %]</label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <input id="email" type="text" class="form-control" name="email" class="validator_position_right" />
                        <span class="help-block">[% locale.maketext('Provide a valid email address where you can be contacted for verification of domain ownership.') %]</span>
                    </div>
                    <div id="email_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label id="lblFriendlyName" for="friendly_name">[% locale.maketext('Description') %]</label>
                <div class="row">
                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                        <textarea id="friendly_name" type="text" class="form-control" name="friendly_name" class="validator_position_right" rows="2"></textarea>
                    </div>
                    <div id="friendly_name_error" class="col-xs-12 col-sm-6 col-md-6 col-lg-6">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <input id="hidItem" type="hidden" name="item" value="crt" />
                <input id="hidItemname" type="hidden" name="itemname" value="Certificate" />
                <input id="submit-button" type="submit" class="btn btn-primary" value="[% locale.maketext("Generate") %]" title="[% locale.maketext('Click to generate the certificate.') %]" />
            </div>
        </form>
    </div>

    [% INCLUDE _assets/return_link.html.tt return_location='index.html' return_link_text=locale.maketext('Return to SSL Manager') %]

</div><!-- end body-content -->

[% PROCESS 'ssl/ssl_certificate_parse.html.tt' -%]
[% END #wrapper %]

[% BLOCK js_block %]
<script type="text/javascript">
(function() {
    /**
     * This module contains all the page specific constants generated by the server.
     * @module PAGE.Properties
     */
     var PAGE = {
        properties : {
            installable_domains: [% JSON.stringify(list_mail_domains.data.ofeach('domain')) -%],
            has_certs_data: [% has_certs_data ? "true" : "false" %],
            desiredKey: '[% FORM.selkey %]'
        }
    }
     // Publish the PAGE object;
     window["PAGE"] = PAGE;
}());

[% INSERT 'sharedjs/asn1_optimized.js' %]
[% INSERT 'cjt/ssl-min.js' %]
[% INSERT 'sharedjs/ssl_optimized.js' %]
[%
    SET lex_path = CPANEL.get_js_lex_app_rel_path('sharedjs/sslwidgets.js');
    INSERT $lex_path IF lex_path;
    INSERT 'sharedjs/sslwidgets_optimized.js';
%]
[%
    SET lex_path = CPANEL.get_js_lex_app_rel_path('js2/ssl/crts.js');
    INSERT $lex_path IF lex_path;
    INSERT 'js2/ssl/crts.js';
%]

[% SET lexicon = {
    '[numf,_1] of the [numerate,_2,domain,domains] that you have entered [numerate,_1,is a domain,are domains] that you do not control.' => locale.lextext('[numf,_1] of the [numerate,_2,domain,domains] that you have entered [numerate,_1,is a domain,are domains] that you do not control.'),
    'A certificate with a key shorter than [quant,_1,bit,bits] is insecure.' => locale.lextext('A certificate with a key shorter than [quant,_1,bit,bits] is insecure.'),
    'A certificate with a key shorter than [quant,_1,bit,bits] is not supported.' => locale.lextext('A certificate with a key shorter than [quant,_1,bit,bits] is not supported.'),
    'Choose a country.' => locale.lextext('Choose a country.')
    'Domain' => locale.lextext('Domain'),
    'Private Key' => locale.lextext('Private Key'),
    'Processing …' => locale.lextext('Processing …'),
    'SSLCity' => locale.lextext('City'),
    'SSLCoDivision' => locale.lextext('Company Division'),
    'SSLCompany' => locale.lextext('Company'),
    'SSLCountry' => locale.lextext('Country'),
    'SSLCountry' => locale.lextext('Country'),
    'SSLEmail' => locale.lextext('Email'),
    'SSLState' => locale.lextext('State'),
    'The certificate’s key is shorter than the recommended length of [quant,_1,bit,bits].' => locale.lextext('The certificate’s key is shorter than the recommended length of [quant,_1,bit,bits].'),
    'This field should only contain letters, numbers, and basic punctuation (e.g., period, dash, space, underscore, comma).' => locale.lextext('This field should only contain letters, numbers, and basic punctuation (e.g., period, dash, space, underscore, comma).'),
    'ValidatorCity' => locale.maketext('The “[_1]” field cannot be left blank.', locale.maketext('City')),
    'ValidatorCompany' => locale.maketext('The “[_1]” field cannot be left blank.', locale.maketext('Company')),
    'ValidatorCompanyDiv' => locale.maketext('The “[_1]” field cannot be left blank.', locale.maketext('Company Division')),
    'ValidatorEmailEmpty' => locale.maketext('The “[_1]” field cannot be left blank.', locale.maketext('Email Address')),
    'ValidatorEmailFormat' => locale.lextext('Please use an email format (for example: [asis,user@example.com]).'),
    'ValidatorState' => locale.maketext('The “[_1]” field cannot be left blank.', locale.maketext('State')),
    'You can only enter valid domains.' => locale.lextext('You can only enter valid domains.'),
    'You do not control this domain.' => locale.lextext('You do not control this domain.'),
} -%]

YAHOO.lang.augmentObject( LOCALE.LEXICON, [% lexicon.json() %] );

[%
    SET lex_path = CPANEL.get_js_lex_app_rel_path('sharedjs/form_submit_handler.js');
    INSERT $lex_path IF lex_path;
    INSERT 'sharedjs/form_submit_handler_optimized.js';
%]
</script>

[% PROCESS _assets/_ajaxapp_footer.html.tt -%]
[% END %]
Back to Directory File Manager