MCPcopy
hub / github.com/FiloSottile/mkcert / Run

Method Run

main.go:171–238  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

169}
170
171func (m *mkcert) Run(args []string) {
172 m.CAROOT = getCAROOT()
173 if m.CAROOT == "" {
174 log.Fatalln("ERROR: failed to find the default CA location, set one as the CAROOT env var")
175 }
176 fatalIfErr(os.MkdirAll(m.CAROOT, 0755), "failed to create the CAROOT")
177 m.loadCA()
178
179 if m.installMode {
180 m.install()
181 if len(args) == 0 {
182 return
183 }
184 } else if m.uninstallMode {
185 m.uninstall()
186 return
187 } else {
188 var warning bool
189 if storeEnabled("system") && !m.checkPlatform() {
190 warning = true
191 log.Println("Note: the local CA is not installed in the system trust store.")
192 }
193 if storeEnabled("nss") && hasNSS && CertutilInstallHelp != "" && !m.checkNSS() {
194 warning = true
195 log.Printf("Note: the local CA is not installed in the %s trust store.", NSSBrowsers)
196 }
197 if storeEnabled("java") && hasJava && !m.checkJava() {
198 warning = true
199 log.Println("Note: the local CA is not installed in the Java trust store.")
200 }
201 if warning {
202 log.Println("Run \"mkcert -install\" for certificates to be trusted automatically ⚠️")
203 }
204 }
205
206 if m.csrPath != "" {
207 m.makeCertFromCSR()
208 return
209 }
210
211 if len(args) == 0 {
212 flag.Usage()
213 return
214 }
215
216 hostnameRegexp := regexp.MustCompile(`(?i)^(\*\.)?[0-9a-z_-]([0-9a-z._-]*[0-9a-z_-])?$`)
217 for i, name := range args {
218 if ip := net.ParseIP(name); ip != nil {
219 continue
220 }
221 if email, err := mail.ParseAddress(name); err == nil && email.Address == name {
222 continue
223 }
224 if uriName, err := url.Parse(name); err == nil && uriName.Scheme != "" && uriName.Host != "" {
225 continue
226 }
227 punycode, err := idna.ToASCII(name)
228 if err != nil {

Callers 3

checkNSSMethod · 0.80
uninstallNSSMethod · 0.80
mainFunction · 0.80

Calls 11

loadCAMethod · 0.95
installMethod · 0.95
uninstallMethod · 0.95
checkPlatformMethod · 0.95
checkNSSMethod · 0.95
checkJavaMethod · 0.95
makeCertFromCSRMethod · 0.95
makeCertMethod · 0.95
getCAROOTFunction · 0.85
fatalIfErrFunction · 0.85
storeEnabledFunction · 0.85

Tested by

no test coverage detected