-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
124 lines (109 loc) · 6.33 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<!doctype html>
<html lang="ru">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="yandex-verification" content="e60f24923515d2eb" />
<title>Проверка наличия сертификатов Минцифры</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
</head>
<body>
<div class="container" id="content">
<div class="row">
<h1>Проверка наличия сертификатов Минцифры</h1>
<p>Это пример реализации проверки наличия корневых сертификатов Минцифры.</p>
<p>Вы можете использовать этот пример для реализации на своем сайте, например, если у вас реализован
аквайринг через Сбер и есть вероятность, что браузер клиента не сможет отобразить страницу платежного
гейта.</p>
<h2>Как использовать</h2>
<div>
<ol>
<li>Включите в клиентский код своего сайта фрагмент, приведённый ниже.</li>
<li>Реализуйте отображение предупреждения тем способом, который принят у вас на сайте.</li>
<li>Устанавливайте в коде куку "skipSslCheck", если не хотите допекать пользователя сообщением на
каждой странице.</li>
<li>Профит.</li>
</ol>
</div>
<pre>
const e = new XMLHttpRequest
e.open("GET", "https://www.sberbank.ru/", !0),
e.addEventListener("load", (() => {
// действие если всё ОК
}
)),
e.onerror = function () {
if (!document.cookie.match(/^(.*;)?\s*skipSslCheck\s*=\s*[^;]+(.*)?$/)) {
// действие, если корневых нет.
}
},
e.send()
</pre>
<h2>Если вам кажется, что пример не работает</h2>
<p>Этот пример выставляет куку после показа сообщения. Это сделано намерено для того, чтобы не мозолить глаза посетителю сайта каждый раз.</p>
<p>Если вы тут не первый раз, сбросьте куки и снова увидите сообщение.</p>
<p><button type="button" class="btn btn-success col-3" id="resetCookie">Сбросить куку</button></p>
<h2>Дисклаймер</h2>
<p>Да, я знаю, что в модальном окне ссылка на Сбер с https в начале.</p>
<p>Да,я понимаю, что в идеале она должна быть кликабельной.</p>
<p>Я ничего с этим делать не буду, это демо. Допиливайте под себя как надо. Я ни разу не фронтэндер, пример основан на коде с сайта Сбера.</p>
<h2>Об авторе</h2>
<ul class="list-group">
<li class="list-group-item">
<a href="https://github.com/igolets">Илья Голец</a>
</li>
<li class="list-group-item">
<a href="https://github.com/igolets/RuSslCheck">Страница проекта с исходным кодом</a>
</li>
</ul>
</div>
</div>
<div class="modal" id="sslModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Нет поддержки SSL</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Ваш браузер не поддерживает сертификаты SSL от Минцифры.</p>
<p>Некоторые функции могут работать некорректно.</p>
<p>Рекомендуется установить сертификаты согласно инструкции https://www.sberbank.ru/ru/certificates.
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Понятно</button>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous">
</script>
<script type="text/javascript">
var myModalEl = document.getElementById('sslModal');
var myModal = new bootstrap.Modal(myModalEl, { keyboard: false });
myModalEl.addEventListener('hide.bs.modal', function (event) {
document.cookie = "skipSslCheck=y; max-age=1209600";
});
const e = new XMLHttpRequest;
e.open("GET", "https://www.sberbank.ru/", !0),
e.addEventListener("load", (() => {
console.log("Success");
}
)),
e.onerror = function () {
if (!document.cookie.match(/^(.*;)?\s*skipSslCheck\s*=\s*[^;]+(.*)?$/)) {
myModal.show();
}
},
e.send()
function resetCookie() {
document.cookie = "skipSslCheck=y; max-age=-1";
window.alert("Готово. Обновите страницу браузера.");
}
document.getElementById("resetCookie").onclick = resetCookie;
</script>
</body>
</html>