@@ -38,7 +38,7 @@ func (m *mkcert) installPlatform() bool {
3838 fatalIfErr (err , "failed to read root certificate" )
3939 // Decode PEM
4040 if certBlock , _ := pem .Decode (cert ); certBlock == nil || certBlock .Type != "CERTIFICATE" {
41- fatalIfErr (fmt .Errorf ("Invalid PEM data" ), "decode pem" )
41+ fatalIfErr (fmt .Errorf ("invalid PEM data" ), "decode pem" )
4242 } else {
4343 cert = certBlock .Bytes
4444 }
@@ -60,7 +60,7 @@ func (m *mkcert) uninstallPlatform() bool {
6060 // Do the deletion
6161 deletedAny , err := store .deleteCertsWithSerial (m .caCert .SerialNumber )
6262 if err == nil && ! deletedAny {
63- err = fmt .Errorf ("No certs found" )
63+ err = fmt .Errorf ("no certs found" )
6464 }
6565 fatalIfErr (err , "delete cert" )
6666 return true
@@ -69,19 +69,23 @@ func (m *mkcert) uninstallPlatform() bool {
6969type windowsRootStore uintptr
7070
7171func openWindowsRootStore () (windowsRootStore , error ) {
72- store , _ , err := procCertOpenSystemStoreW .Call (0 , uintptr (unsafe .Pointer (syscall .StringToUTF16Ptr ("ROOT" ))))
72+ rootStr , err := syscall .UTF16PtrFromString ("ROOT" )
73+ if err != nil {
74+ return 0 , err
75+ }
76+ store , _ , err := procCertOpenSystemStoreW .Call (0 , uintptr (unsafe .Pointer (rootStr )))
7377 if store != 0 {
7478 return windowsRootStore (store ), nil
7579 }
76- return 0 , fmt .Errorf ("Failed to open windows root store: %v" , err )
80+ return 0 , fmt .Errorf ("failed to open windows root store: %v" , err )
7781}
7882
7983func (w windowsRootStore ) close () error {
8084 ret , _ , err := procCertCloseStore .Call (uintptr (w ), 0 )
8185 if ret != 0 {
8286 return nil
8387 }
84- return fmt .Errorf ("Failed to close windows root store: %v" , err )
88+ return fmt .Errorf ("failed to close windows root store: %v" , err )
8589}
8690
8791func (w windowsRootStore ) addCert (cert []byte ) error {
@@ -97,7 +101,7 @@ func (w windowsRootStore) addCert(cert []byte) error {
97101 if ret != 0 {
98102 return nil
99103 }
100- return fmt .Errorf ("Failed adding cert: %v" , err )
104+ return fmt .Errorf ("failed adding cert: %v" , err )
101105}
102106
103107func (w windowsRootStore ) deleteCertsWithSerial (serial * big.Int ) (bool , error ) {
@@ -111,7 +115,7 @@ func (w windowsRootStore) deleteCertsWithSerial(serial *big.Int) (bool, error) {
111115 if errno , ok := err .(syscall.Errno ); ok && errno == 0x80092004 {
112116 break
113117 }
114- return deletedAny , fmt .Errorf ("Failed enumerating certs: %v" , err )
118+ return deletedAny , fmt .Errorf ("failed enumerating certs: %v" , err )
115119 }
116120 // Parse cert
117121 certBytes := (* [1 << 20 ]byte )(unsafe .Pointer (cert .EncodedCert ))[:cert .Length ]
@@ -121,10 +125,10 @@ func (w windowsRootStore) deleteCertsWithSerial(serial *big.Int) (bool, error) {
121125 // Duplicate the context so it doesn't stop the enum when we delete it
122126 dupCertPtr , _ , err := procCertDuplicateCertificateContext .Call (uintptr (unsafe .Pointer (cert )))
123127 if dupCertPtr == 0 {
124- return deletedAny , fmt .Errorf ("Failed duplicating context: %v" , err )
128+ return deletedAny , fmt .Errorf ("failed duplicating context: %v" , err )
125129 }
126130 if ret , _ , err := procCertDeleteCertificateFromStore .Call (dupCertPtr ); ret == 0 {
127- return deletedAny , fmt .Errorf ("Failed deleting certificate: %v" , err )
131+ return deletedAny , fmt .Errorf ("failed deleting certificate: %v" , err )
128132 }
129133 deletedAny = true
130134 }
0 commit comments