/
snap
/
lxd
/
current
/
share
/
lxd-ui
/
assets
/
File Upload :
llllll
Current File: //snap/lxd/current/share/lxd-ui/assets/CertificateGenerate-DPnPCaLN.js
import{r as m,f as v,g as _,h as k,i as y,j as e,d as i,u as I,c as S,b as M,N as G}from"./index-dL2n30-Z.js";const F=({onConfirm:s,onClose:o,isPasswordRequired:r})=>{const[a,n]=m.useState(r),c=v().shape({password:_(),passwordConfirm:_().oneOf([k("password"),""],"Passwords must match")}),t=y({initialValues:{password:"",passwordConfirm:""},validationSchema:c,onSubmit:x=>{s(x.password)}}),h=()=>{s("")};return e.jsxs(i.Modal,{close:o,title:"Create Certificate",buttonRow:e.jsx(e.Fragment,{children:a?e.jsx(i.ActionButton,{appearance:"positive",className:"u-no-margin--bottom",onClick:()=>void t.submitForm(),disabled:t.values.password!==t.values.passwordConfirm||t.values.password.length===0,children:"Generate and download"}):e.jsx(i.Button,{appearance:"positive",className:"u-no-margin--bottom",onClick:h,children:"Generate and download"})}),children:[e.jsx(i.Notification,{severity:"caution",className:"u-no-margin--bottom",children:"Passwords are required for client certificates on macOS. On other platforms, a password is optional."}),e.jsx(i.Switch,{label:"Password protected",checked:a,onChange:()=>{n(!a)}}),a&&e.jsxs(e.Fragment,{children:[e.jsx(i.Input,{id:"password",type:"password",label:"Password",onBlur:t.handleBlur,onChange:t.handleChange,value:t.values.password,error:t.touched.password?t.errors.password:null}),e.jsx(i.Input,{id:"passwordConfirm",type:"password",label:"Confirm password",onBlur:t.handleBlur,onChange:t.handleChange,value:t.values.passwordConfirm,error:t.touched.passwordConfirm?t.errors.passwordConfirm:null})]})]})},R=({isPasswordRequired:s})=>{const[o,r]=m.useState(!1),[a,n]=m.useState(!1),[c,t]=m.useState(null),h=()=>{n(!1)},x=()=>{n(!0)},C=f=>{h(),r(!0);const l=new Worker(new URL("/ui/assets/certificate-CjDjm-lw.js",import.meta.url),{type:"module"});l.onmessage=d=>{t(d.data),r(!1),N(`lxd-ui-${location.hostname}.pfx`,d.data.pfx),l.terminate()},l.onerror=d=>{console.error("Web Worker error:",d),r(!1),l.terminate()},l.postMessage(f)},N=(f,l)=>{const d=`data:application/octet-stream;base64,${l}`,j=document.createElement("a");j.href=d,j.download=f,j.click()};return e.jsxs(e.Fragment,{children:[a&&e.jsx(F,{onClose:h,onConfirm:C,isPasswordRequired:s}),e.jsxs("div",{children:[e.jsxs(i.Button,{onClick:x,disabled:o||c!==null,className:"u-no-margin--bottom",hasIcon:!0,"aria-label":`${o?"Generating":"Generate"} certificate`,children:[o?e.jsx(i.Icon,{className:"u-animation--spin",name:"spinner"}):e.jsx(i.Icon,{name:"begin-downloading",alt:"download"}),e.jsx("span",{children:o?"Generating":"Generate certificate"})]}),c!==null&&e.jsx(i.Icon,{name:"success"})]})]})},p="Firefox",w="Chrome on Linux",b="Chrome on Windows",g="Microsoft Edge",u="macOS",L=[p,w,b,g,u],E=()=>{const s=navigator.userAgent.toLowerCase(),o=s.includes("macintosh")||s.includes("mac os"),r=s.includes("windows"),a=s.includes("linux"),n=s.includes("edg/"),c=s.includes("firefox"),t=s.includes("chrome");return c?p:o?u:n?g:t&&r?b:t&&a?w:p},B=()=>{const[s,o]=m.useState(E()),r=e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:"p-list__item",children:["In the modal that appears, click ",e.jsx("b",{children:"Import..."})]}),e.jsxs("li",{className:"p-list__item",children:["Follow the instructions in the Certificate Import Wizard. When prompted with ",e.jsx("b",{children:"File to Import"}),", click ",e.jsx("b",{children:"Browse"})," and choose the certificate you downloaded. In order to see the certificate file, ensure that the file type picker is set to"," ",e.jsx("b",{children:"Personal Information Exchange (*.pfx;*.p12)"}),"."]}),e.jsx("li",{className:"p-list__item",children:e.jsx("b",{children:"Restart the browser."})})]}),a=e.jsxs("li",{className:"p-list__item u-clearfix",children:["Create and download a client certificate:",e.jsx(R,{isPasswordRequired:s===u})]});return e.jsx(i.Row,{children:e.jsxs(i.Col,{size:10,children:[e.jsx(i.Tabs,{links:L.map(n=>({label:n,active:n===s,onClick:()=>{o(n)}}))}),s===p&&e.jsx("div",{role:"tabpanel","aria-label":"firefox",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[a,e.jsxs("li",{className:"p-list__item",children:["Go to Firefox’s privacy settings:",e.jsx("pre",{className:"p-code-snippet__block u-no-margin--bottom",children:e.jsx("code",{children:"about:preferences#privacy"})})]}),e.jsxs("li",{className:"p-list__item",children:["Scroll down to the certificates section and click"," ",e.jsx("b",{children:"View Certificates"})]}),e.jsxs("li",{className:"p-list__item",children:["In the modal that appears, go to Your ",e.jsx("b",{children:"certificates"})," and click Import"]}),e.jsx("li",{className:"p-list__item",children:"Select the .pfx file you just downloaded. If you created a password for the certificate, type it in now."}),e.jsx("li",{className:"p-list__item",children:e.jsx("b",{children:"Restart the browser."})})]})}),s===w&&e.jsx("div",{role:"tabpanel","aria-label":"chrome linux",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[a,e.jsxs("li",{className:"p-list__item",children:["Go to Chrome's certificate manager:",e.jsx("pre",{className:"p-code-snippet__block u-no-margin--bottom",children:e.jsx("code",{children:"chrome://certificate-manager"})})]}),e.jsxs("li",{className:"p-list__item",children:["Click ",e.jsx("b",{children:"Your certificates"})]}),e.jsxs("li",{className:"p-list__item",children:["Go to ",e.jsx("b",{children:"View imported certificates from Linux"})]}),e.jsxs("li",{className:"p-list__item",children:["Select ",e.jsx("b",{children:"Import"})," and choose the .pfx file you just downloaded. If you created a password for the certificate, type it in now."]}),e.jsx("li",{className:"p-list__item",children:e.jsx("b",{children:"Restart the browser."})})]})}),s===b&&e.jsx("div",{role:"tabpanel","aria-label":"chrome windows",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[a,e.jsxs("li",{className:"p-list__item",children:["Go to Chrome's certificate settings:",e.jsx("pre",{className:"p-code-snippet__block u-no-margin--bottom",children:e.jsx("code",{children:"chrome://settings/certificates"})})]}),e.jsxs("li",{className:"p-list__item",children:["Near the bottom of the page, click ",e.jsx("b",{children:"Manage certificates"})]}),e.jsxs("li",{className:"p-list__item",children:["Make sure"," ",e.jsx("b",{children:"Use imported local certificates from your operating system"})," ","is toggled on, and click"," ",e.jsx("b",{children:"Manage imported certificates from Windows"})," "]}),r]})}),s===g&&e.jsx("div",{role:"tabpanel","aria-label":"edge windows",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[a,e.jsxs("li",{className:"p-list__item",children:["Go to Edge's certificate settings:",e.jsx("pre",{className:"p-code-snippet__block u-no-margin--bottom",children:e.jsx("code",{children:"edge://settings/privacy"})})]}),e.jsxs("li",{className:"p-list__item",children:["Under ",e.jsx("b",{children:"Security"}),", click ",e.jsx("b",{children:"Manage certificates"})]}),r]})}),s===u&&e.jsx("div",{role:"tabpanel","aria-label":"safari macos",children:e.jsxs("ul",{className:"p-list--divided u-no-margin--bottom",children:[a,e.jsxs("li",{className:"p-list__item",children:["Launch the ",e.jsx("b",{children:"Keychain Access app"})," (you will need to authenticate using your mac’s login credentials)"]}),e.jsxs("li",{className:"p-list__item",children:["Import the certificate file that was created earlier. This can be done either by dragging the file from Finder onto Keychain Access, or with ",e.jsx("b",{children:" File > Import Items..."})]}),e.jsx("li",{className:"p-list__item",children:"Unlock the certificate by typing in the password used to create it."}),e.jsx("li",{className:"p-list__item",children:e.jsx("b",{children:"Restart the browser."})})]})})]})})},P=()=>{const{isAuthenticated:s,isAuthLoading:o}=I(),r=S(),{data:a}=M(),n=a==null?void 0:a.client_certificate;return o?e.jsx(i.Spinner,{className:"u-loader",text:"Loading...",isMainComponent:!0}):s?e.jsx(G,{to:"/ui",replace:!0}):e.jsx(i.CustomLayout,{mainClassName:"certificates",children:e.jsxs(i.Row,{children:[e.jsx(i.Col,{size:1}),e.jsxs(i.Col,{size:10,children:[e.jsx(i.Notification,{actions:n?[]:[{label:"I already have a client certificate",onClick:()=>{r("/ui/login/certificate-add")}}],title:"TLS login",severity:"information",children:"LXD uses mutual TLS for server client-server authentication. Your browser must have a client certificate installed and selected in order to proceed."}),n&&e.jsx(i.Notification,{actions:[{label:"Skip to step 2",onClick:()=>{r("/ui/login/certificate-add")}}],title:"Client certificate already present",severity:"positive",children:"It looks like you you already have a client certificate installed and selected, skip to the next step."}),e.jsx(B,{})]})]})})};export{P as default};
Copyright ©2k19 -
Hexid
|
Tex7ure