ProHoster > ΠΠ»ΠΎΠ³ > Kev tswj hwm > Yuav ua li cas peb ntawm ZeroTech txuas Apple Safari thiab daim ntawv pov thawj cov neeg siv khoom nrog websockets
Yuav ua li cas peb ntawm ZeroTech txuas Apple Safari thiab daim ntawv pov thawj cov neeg siv khoom nrog websockets
Kab lus yuav pab tau rau cov neeg uas:
paub tias Client Cert yog dab tsi thiab nkag siab tias vim li cas nws xav tau websockets ntawm mobile Safari;
Kuv xav tshaj tawm cov kev pabcuam hauv lub vev xaib rau ib lub voj voog ntawm tib neeg lossis tsuas yog rau kuv tus kheej xwb;
xav tias txhua yam twb tau ua los ntawm ib tug neeg, thiab xav ua kom lub ntiaj teb no yooj yim dua thiab nyab xeeb dua.
Keeb kwm ntawm websockets pib txog 8 xyoo dhau los. Yav dhau los, txoj kev tau siv nyob rau hauv daim ntawv thov ntev http (ua tau cov lus teb): tus neeg siv lub browser xa ib daim ntawv thov mus rau lub server thiab tos kom nws teb ib yam dab tsi, tom qab cov lus teb nws txuas dua thiab tos. Tab sis ces websockets tshwm.
Ob peb xyoos dhau los, peb tau tsim peb tus kheej kev siv hauv PHP ntshiab, uas tsis tuaj yeem siv https thov, vim qhov no yog txheej txheej txuas. Tsis ntev tas los no, yuav luag tag nrho cov web servers tau kawm rau npe thov dhau https thiab txhawb kev sib txuas: txhim kho.
Thaum qhov no tshwm sim, websockets tau dhau los ua qhov kev pabcuam ua ntej rau SPA daim ntawv thov, vim tias nws yooj yim npaum li cas los muab cov ntsiab lus rau tus neeg siv ntawm qhov pib ntawm tus neeg rau zaub mov (xa xov los ntawm lwm tus neeg siv lossis rub tawm cov ntawv tshiab ntawm cov duab, ntaub ntawv, kev nthuav qhia. uas lwm tus tab tom kho tam sim no).
Txawm hais tias Client Certificate tau nyob ib puag ncig rau qee lub sijhawm, nws tseem tsis txaus ntseeg, vim nws tsim teeb meem ntau thaum sim hla nws. Thiab (tejzaum nws :slightly_smiling_face: ) yog vim li cas IOS browsers (txhua tus tsuas yog Safari) tsis xav siv nws thiab thov nws los ntawm lub khw muag ntawv pov thawj hauv zos. Cov ntawv pov thawj muaj ntau qhov zoo piv rau tus ID nkag mus / hla lossis ssh yuam sij lossis kaw cov chaw nres nkoj tsim nyog los ntawm firewall. Tab sis qhov tsis yog qhov no yog hais txog.
Hauv iOS no, cov txheej txheem rau kev txhim kho daim ntawv pov thawj yog qhov yooj yim heev (tsis yog tsis muaj qhov tshwj xeeb), tab sis feem ntau nws ua tiav raws li cov lus qhia, uas muaj ntau hauv Is Taws Nem thiab tsuas yog muaj rau Safari browser. Hmoov tsis zoo, Safari tsis paub yuav ua li cas siv Client Π‘ert rau lub vev xaib, tab sis muaj ntau cov lus qhia hauv Is Taws Nem txog kev tsim daim ntawv pov thawj zoo li no, tab sis hauv kev xyaum qhov no tsis tuaj yeem ua tiav.
Txhawm rau nkag siab cov websockets, peb siv cov phiaj xwm hauv qab no: teeb meem/hypothesis/solution.
Teeb meem: tsis muaj kev txhawb nqa rau lub vev xaib lub vev xaib thaum tso npe thov rau cov peev txheej uas tau txais kev tiv thaiv los ntawm daim ntawv pov thawj tus neeg siv khoom ntawm Safari mobile browser rau IOS thiab lwm yam kev siv uas tau txais kev txhawb nqa daim ntawv pov thawj.
Hypotheses:
Nws muaj peev xwm los teeb tsa qhov kev zam rau siv daim ntawv pov thawj (paub tias yuav tsis muaj) rau websockets ntawm cov khoom siv sab hauv / sab nraud.
Kev sib tham ib ntus tuaj yeem siv tau siv ib tus neeg siv lub vev xaib proxy (built-in modules thiab ua haujlwm nkaus xwb).
Kev sib tham ib ntus tokens twb tau ua tiav raws li npaj ua Apache modules.
Kev sib tham ib ntus tokens tuaj yeem siv los ntawm kev tsim cov qauv kev sib cuam tshuam.
Pom lub xeev tom qab siv.
Lub hom phiaj ntawm kev ua haujlwm: kev tswj hwm cov kev pabcuam thiab kev tsim kho vaj tse yuav tsum nkag mus tau los ntawm lub xov tooj ntawm tes ntawm IOS yam tsis muaj kev pabcuam ntxiv (xws li VPN), koom ua ke thiab ruaj ntseg.
Lub hom phiaj ntxiv: txuag lub sijhawm thiab cov peev txheej / xov tooj tsheb (qee qhov kev pabcuam tsis muaj lub vev xaib tsim tsim cov kev thov tsis tsim nyog) nrog kev xa cov ntsiab lus sai dua hauv Is Taws Nem.
Kev txheeb xyuas daim ntawv pov thawj tshwm sim tom qab kev thov rau cov peev txheej proxied, uas yog, tom qab thov tuav tes. Qhov no txhais tau hais tias lub npe yuav xub thauj khoom thiab tom qab ntawd txiav tawm qhov kev thov mus rau qhov kev pabcuam tiv thaiv. Qhov no yog qhov phem, tab sis tsis tseem ceeb;
Hauv http2 raws tu qauv. Nws tseem nyob rau hauv cov cua ntsawj ntshab, thiab browser manufacturers tsis paub yuav ua li cas siv nws #info txog tls1.3 http2 post handshake (tsis ua hauj lwm tam sim no) Siv RFC 8740 "Siv TLS 1.3 nrog HTTP/2";
Nws tsis paub meej tias yuav ua li cas koom ua ke qhov kev ua tiav no.
b) Ntawm theem pib, tso cai rau ssl yam tsis muaj daim ntawv pov thawj.
SSLVerifyClient xav tau => SSLVerifyClient xaiv tau, tab sis qhov no txo ββqis qib kev ruaj ntseg ntawm lub npe neeg rau zaub mov, vim tias qhov kev sib txuas no yuav ua tiav yam tsis muaj daim ntawv pov thawj. Txawm li cas los xij, koj tuaj yeem txwv tsis pub nkag mus rau cov kev pabcuam proxied nrog cov lus qhia hauv qab no:
RewriteEngine on
RewriteCond %{SSL:SSL_CLIENT_VERIFY} !=SUCCESS
RewriteRule .? - [F]
ErrorDocument 403 "You need a client side certificate issued by CAcert to access this site"
Raws li kev paub dhau los, koj yuav tsum tau ntxiv ib ntu ntxiv rau kev teeb tsa txhawm rau npaj cov tokens ib ntus rau kev sib txuas hauv lub vev xaib thaum lub sijhawm thov tsis tu ncua (tsis yog lub vev xaib).
Kev sim tau pom tias nws ua haujlwm. Nws muaj peev xwm hloov cov ncuav qab zib rau koj tus kheej los ntawm tus neeg siv tus browser.
3. Kev sib tham ib ntus tuaj yeem siv tau siv ib lub vev xaib tus neeg rau zaub mov (tsuas yog cov qauv tsim thiab ua haujlwm).
Raws li peb pom yav dhau los, Apache muaj ntau ntau ntawm cov haujlwm tseem ceeb uas tso cai rau koj los tsim cov qauv tsim. Txawm li cas los xij, peb xav tau txhais tau tias los tiv thaiv peb cov ntaub ntawv thaum nws nyob hauv tus neeg siv lub browser, yog li peb tsim kom muaj dab tsi khaws thiab vim li cas, thiab cov haujlwm ua haujlwm li cas peb yuav siv:
Peb xav tau lub token uas tsis tuaj yeem txiav txim siab yooj yim.
Peb xav tau ib tug token uas muaj obsolescence tsim rau hauv nws thiab muaj peev xwm los xyuas obsolescence ntawm lub server.
Peb xav tau ib qho token uas yuav cuam tshuam nrog tus tswv ntawm daim ntawv pov thawj.
Qhov no yuav tsum muaj hashing muaj nuj nqi, ntsev, thiab hnub nyoog rau lub hnub nyoog token. Raws li cov ntaub ntawv Cov lus qhia hauv Apache HTTP Server peb muaj tag nrho tawm ntawm lub thawv sha1 thiab %{TIME}.
Npaj-ua modules yog qhov nyuaj heev, vim tias peb tsuas xav tau ob peb txoj haujlwm xwb.
Uas tau hais tias, qhov teeb meem nrog rau hnub yog tias Apache lub zog ua haujlwm tsis tso cai tsim hnub los ntawm lub neej yav tom ntej, thiab tsis muaj lej ntxiv / rho tawm hauv cov haujlwm ua haujlwm thaum kuaj xyuas qhov ploj lawm.
Ntawd yog, koj tsis tuaj yeem sau:
(%{env:zt-cert-date} + 30) > %{DATE}
Koj tsuas tuaj yeem sib piv ob tus lej.
Thaum tab tom nrhiav kev daws teeb meem rau Safari, kuv pom ib tsab xov xwm nthuav: Kev ruaj ntseg HomeAssistant nrog daim ntawv pov thawj cov neeg siv khoom (ua haujlwm nrog Safari / iOS)
Nws piav qhia txog ib qho piv txwv ntawm cov cai hauv Lua rau Nginx, thiab uas, raws li nws tau muab tawm, ntau heev rov ua qhov kev xav ntawm qhov ntawm qhov kev teeb tsa uas peb tau ua tiav, tshwj tsis yog kev siv hmac salting txoj kev rau hashing ( qhov no tsis pom hauv Apache).
Nws tau pom tseeb tias Lua yog ib hom lus uas muaj qhov tseeb, thiab nws muaj peev xwm ua tau ib yam dab tsi yooj yim rau Apache:
Peb nrhiav tau ib txoj hauv kev los teeb env variables nyob rau hauv ib tug me me Lua cov ntaub ntawv nyob rau hauv thiaj li yuav teem ib hnub los ntawm yav tom ntej los piv nrog rau tam sim no.
Nov yog qhov yooj yim Lua tsab ntawv zoo li:
require 'apache2'
function handler(r)
local fmt = '%Y%m%d%H%M%S'
local timeout = 3600 -- 1 hour
r.notes['zt-cert-timeout'] = timeout
r.notes['zt-cert-date-next'] = os.date(fmt,os.time()+timeout)
r.notes['zt-cert-date-halfnext'] = os.date(fmt,os.time()+ (timeout/2))
r.notes['zt-cert-date-now'] = os.date(fmt,os.time())
return apache2.OK
end
Thiab qhov no yog li cas nws ua haujlwm tag nrho, nrog kev ua kom zoo ntawm cov ncuav qab zib thiab hloov lub token thaum ib nrab lub sij hawm los txog ua ntej lub ncuav qab zib qub (token) tas sijhawm:
Feem ntau, nws tsis muaj teeb meem nyob rau hauv qhov kev txiav txim cov lus qhia tau sau rau hauv Apache (tej zaum kuj Nginx) kev teeb tsa, txij li thaum kawg txhua yam yuav raug txheeb raws li qhov kev txiav txim ntawm qhov kev thov los ntawm tus neeg siv, uas sib haum rau cov txheej txheem rau kev ua haujlwm. Lus scripts.
Ua tiav:
Pom lub xeev tom qab ua tiav (lub hom phiaj):
kev tswj hwm cov kev pabcuam thiab kev tsim kho vaj tse yog muaj los ntawm lub xov tooj ntawm tes ntawm IOS yam tsis muaj kev pabcuam ntxiv (VPN), koom ua ke thiab ruaj ntseg.
Lub hom phiaj tau ua tiav, qhov web sockets ua haujlwm thiab muaj qib kev ruaj ntseg tsis tsawg dua li daim ntawv pov thawj.