{$layout}

{$var "header"}
	<script src="/servers/certs/datajs" type="text/javascript"></script>
	<script src="/js/sortable.min.js" type="text/javascript"></script>
{$end}

{$template "../settings_menu"}
{$template "/left_menu_with_menu"}

<div class="right-box with-menu https-config-container">
    <div class="https-config-form">
        <div class="form-title">HTTPS配置</div>
        
        <div class="audit-message info">
            <i class="icon info circle"></i>
            <div>提醒：HTTP/2、证书等信息修改后，可能需要清空浏览器缓存后才能浏览效果。</div>
        </div>

        <div v-if="httpsConfig.isOn && missingCertServerNames !=null && missingCertServerNames.length > 0" class="audit-message warning">
            <i class="icon exclamation triangle"></i>
            <div>警告：当前网站绑定的以下域名尚未配置证书，将无法通过HTTPS协议访问：{{missingCertServerNames.join("、")}} 。</div>
        </div>

        <form method="post" class="ui form" data-tea-action="$" data-tea-success="success" id="https-config-form">
            <input type="hidden" name="serverId" :value="serverId"/>
            <input type="hidden" name="serverType" :value="serverType"/>
            
            <div class="config-section">
                <div class="section-title">
                    <i class="icon lock"></i>
                    <span>基本设置</span>
                </div>
                
                <div class="config-item">
                    <div class="item-label">启用HTTPS</div>
                    <div class="item-content">
                        <p-switch name="isOn" value="1" v-model="httpsConfig.isOn" binary @change="submit"></p-switch>
                    </div>
                </div>
                <div class="config-item">
					<div class="item-label">HTTPS端口</div>
					<div class="item-content">
						<p class="comment" v-if="httpsConfig.isOn && (httpsConfig.addresses == null || httpsConfig.addresses.length == 0)">
                            <span class="red">还没有添加端口绑定，会导致HTTPS服务无法访问。</span>
                        </p>
                        <network-addresses-box :v-server-type="serverType" :v-addresses="httpsConfig.addresses" :v-protocol="'https'"></network-addresses-box>
                        <p class="comment" v-if="conflictingPorts.length > 0">
                            <span class="red">配置错误：<span v-for="(port, index) in conflictingPorts">{{port}}<span v-if="index != conflictingPorts.length - 1">、</span></span><span v-if="conflictingPorts.length > 1">等</span>端口同HTTP设置的端口冲突，请删除HTTP或HTTPS中的相关端口。</span>
                        </p>
					</div>
				</div>
            </div>

            <!-- SSL配置 -->
            <ssl-config-box :v-ssl-policy="httpsConfig.sslPolicy" :v-protocol="'https'" v-show="httpsConfig.isOn" :v-server-id="serverId" :v-support-http3="httpsConfig.supportsHTTP3 && http3FeatureEnabled"></ssl-config-box>

            <div class="margin"></div>
            <submit-btn v-show="httpsConfig.isOn"></submit-btn>
        </form>
    </div>
</div>