]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
mk-ca-bundle.vbs: delete this script in favor of mk-ca-bundle.pl
authorJay Satiro <raysatiro@yahoo.com>
Wed, 9 Feb 2022 08:45:50 +0000 (03:45 -0500)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 10 Mar 2022 22:18:40 +0000 (23:18 +0100)
mk-ca-bundle.vbs is a Windows-specific script for Mozilla certificate
extraction, similar to mk-ca-bundle.pl which runs on any platform. The
vbs version has not been maintained while the perl version has been
maintained with improvements and security fixes. I don't think it's
worth the work to maintain both versions. Windows users should be able
to use mk-ca-bundle.pl without any problems, as long as they have perl.

Closes #8412

lib/Makefile.am
lib/mk-ca-bundle.vbs [deleted file]

index 2e44d37f54092661f33f0d9086356af4b378289d..6e20924b719ac5acc400cd484ecb8fb94c0d34cd 100644 (file)
@@ -26,7 +26,7 @@ CMAKE_DIST = CMakeLists.txt curl_config.h.cmake
 EXTRA_DIST = Makefile.m32 config-win32.h config-win32ce.h config-plan9.h    \
  config-riscos.h config-mac.h curl_config.h.in makefile.dj config-dos.h     \
  libcurl.plist libcurl.rc config-amigaos.h makefile.amiga config-win32ce.h  \
- config-os400.h setup-os400.h mk-ca-bundle.pl mk-ca-bundle.vbs \
+ config-os400.h setup-os400.h mk-ca-bundle.pl \
  $(CMAKE_DIST) firefox-db2pem.sh checksrc.pl setup-win32.h .checksrc
 
 lib_LTLIBRARIES = libcurl.la
diff --git a/lib/mk-ca-bundle.vbs b/lib/mk-ca-bundle.vbs
deleted file mode 100755 (executable)
index 21b4c19..0000000
+++ /dev/null
@@ -1,431 +0,0 @@
-'***************************************************************************\r
-'*                                  _   _ ____  _\r
-'*  Project                     ___| | | |  _ \| |\r
-'*                             / __| | | | |_) | |\r
-'*                            | (__| |_| |  _ <| |___\r
-'*                             \___|\___/|_| \_\_____|\r
-'*\r
-'* Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.\r
-'*\r
-'* This software is licensed as described in the file COPYING, which\r
-'* you should have received as part of this distribution. The terms\r
-'* are also available at https://curl.se/docs/copyright.html.\r
-'*\r
-'* You may opt to use, copy, modify, merge, publish, distribute and/or sell\r
-'* copies of the Software, and permit persons to whom the Software is\r
-'* furnished to do so, under the terms of the COPYING file.\r
-'*\r
-'* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY\r
-'* KIND, either express or implied.\r
-'*\r
-'***************************************************************************\r
-'* Script to fetch certdata.txt from Mozilla.org site and create a\r
-'* ca-bundle.crt for use with OpenSSL / libcurl / libcurl bindings\r
-'* Requires WinHttp.WinHttpRequest.5.1 and ADODB.Stream which are part of\r
-'* W2000 SP3 or later, WXP SP1 or later, W2003 Server SP1 or later.\r
-'* Hacked by Guenter Knauf\r
-'***************************************************************************\r
-Option Explicit\r
-Const myVersion = "0.4.0"\r
-\r
-Const myUrl = "https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt"\r
-\r
-Const myOpenSSL = "openssl.exe"\r
-Dim myUseOpenSSL\r
-myUseOpenSSL = TRUE          ' Flag: TRUE to use OpenSSL. If TRUE and is not\r
-                             ' found then a warning is shown before continuing.\r
-\r
-Const myCdSavF = TRUE        ' Flag: save downloaded data to file certdata.txt\r
-Const myCaBakF = TRUE        ' Flag: backup existing ca-bundle certificate\r
-Const myAskLiF = TRUE        ' Flag: display certdata.txt license agreement\r
-Const myWrapLe = 76          ' Default length of base64 output lines\r
-\r
-' cert info code doesn't work properly with any recent openssl, leave disabled.\r
-' Also: we want our certificate output by default to be as similar as possible\r
-' to mk-ca-bundle.pl and setting this TRUE changes the base64 width to\r
-' OpenSSL's built-in default width, which is not the same as mk-ca-bundle.pl.\r
-Const myAskTiF = FALSE       ' Flag: ask to include certificate text info\r
-\r
-'\r
-'******************* Nothing to configure below! *******************\r
-'\r
-Const adTypeBinary = 1\r
-Const adTypeText = 2\r
-Const adSaveCreateNotExist = 1\r
-Const adSaveCreateOverWrite = 2\r
-Dim objShell, objNetwork, objFSO, objHttp\r
-Dim myBase, mySelf, myStream, myTmpFh, myCdData, myCdFile\r
-Dim myCaFile, myTmpName, myBakNum, myOptTxt, i\r
-Set objNetwork = WScript.CreateObject("WScript.Network")\r
-Set objShell = WScript.CreateObject("WScript.Shell")\r
-Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")\r
-Set objHttp = WScript.CreateObject("WinHttp.WinHttpRequest.5.1")\r
-If objHttp Is Nothing Then Set objHttp = WScript.CreateObject("WinHttp.WinHttpRequest")\r
-myBase = Left(WScript.ScriptFullName, InstrRev(WScript.ScriptFullName, "\"))\r
-mySelf = Left(WScript.ScriptName, InstrRev(WScript.ScriptName, ".") - 1) & " " & myVersion\r
-\r
-myCdFile = Mid(myUrl, InstrRev(myUrl, "/") + 1)\r
-myCaFile = "ca-bundle.crt"\r
-myTmpName = InputBox("It will take a minute to download and parse the " & _\r
-                     "certificate data." & _\r
-                     vbLf & vbLf & _\r
-                     "Please enter the output filename:", mySelf, myCaFile)\r
-If (myTmpName = "") Then\r
-  WScript.Quit 1\r
-End If\r
-myCaFile = myTmpName\r
-If (myCdFile = "") Then\r
-  MsgBox("URL does not contain filename!"), vbCritical, mySelf\r
-  WScript.Quit 1\r
-End If\r
-\r
-' Don't use OpenSSL if it's not present.\r
-If (myUseOpenSSL = TRUE) Then\r
-  Dim errnum\r
-\r
-  On Error Resume Next\r
-  Call objShell.Run("""" & myOpenSSL & """ version", 0, TRUE)\r
-  errnum = Err.Number\r
-  On Error GoTo 0\r
-\r
-  If Not (errnum = 0) Then\r
-    myUseOpenSSL = FALSE\r
-    MsgBox("OpenSSL was not found so the certificate bundle will not " & _\r
-           "include the SHA256 hash of the raw certificate data file " & _\r
-           "that was used to generate the certificates in the bundle. " & _\r
-           vbLf & vbLf & _\r
-           "This does not have any effect on the certificate output, " & _\r
-           "so this script will continue." & _\r
-           vbLf & vbLf & _\r
-           "If you want to set a custom location for OpenSSL or disable " & _\r
-           "this message then edit the variables at the start of the " & _\r
-           "script."), vbInformation, mySelf\r
-  End If\r
-End If\r
-\r
-If (myAskTiF = TRUE) And (myUseOpenSSL = TRUE) Then\r
-  If (6 = objShell.PopUp("Do you want to include text information about " & _\r
-                         "each certificate?" & vbLf & _\r
-                         "(Requires OpenSSL.exe in the current directory " & _\r
-                         "or search path)",, _\r
-          mySelf, vbQuestion + vbYesNo + vbDefaultButton2)) Then\r
-    myOptTxt = TRUE\r
-  Else\r
-    myOptTxt = FALSE\r
-  End If\r
-End If\r
-\r
-' Uncomment the line below to ignore SSL invalid cert errors\r
-' objHttp.Option(4) = 256 + 512 + 4096 + 8192\r
-objHttp.SetTimeouts 0, 5000, 10000, 10000\r
-objHttp.Open "GET", myUrl, FALSE\r
-objHttp.setRequestHeader "User-Agent", WScript.ScriptName & "/" & myVersion\r
-objHttp.Send ""\r
-If Not (objHttp.Status = 200) Then\r
-  MsgBox("Failed to download '" & myCdFile & "': " & objHttp.Status & " - " & objHttp.StatusText), vbCritical, mySelf\r
-  WScript.Quit 1\r
-End If\r
-' Write received data to file if enabled\r
-If (myCdSavF = TRUE) Then\r
-  Call SaveBinaryData(myCdFile, objHttp.ResponseBody)\r
-End If\r
-' Convert data from ResponseBody instead of using ResponseText because of UTF-8\r
-myCdData = ConvertBinaryToUTF8(objHttp.ResponseBody)\r
-Set objHttp = Nothing\r
-' Backup exitsing ca-bundle certificate file\r
-If (myCaBakF = TRUE) Then\r
-  If objFSO.FileExists(myCaFile) Then\r
-    Dim myBakFile, b\r
-    b = 1\r
-    myBakFile = myCaFile & ".~" & b & "~"\r
-    While objFSO.FileExists(myBakFile)\r
-      b = b + 1\r
-      myBakFile = myCaFile & ".~" & b & "~"\r
-    Wend\r
-    Set myTmpFh = objFSO.GetFile(myCaFile)\r
-    myTmpFh.Move myBakFile\r
-  End If\r
-End If\r
-\r
-' Process the received data\r
-Dim myLines, myPattern, myInsideCert, myInsideLicense, myLicenseText, myNumCerts, myNumSkipped\r
-Dim myLabel, myOctets, myData, myPem, myRev, myUntrusted, j\r
-myNumSkipped = 0\r
-myNumCerts = 0\r
-myData = ""\r
-myLines = Split(myCdData, vbLf, -1)\r
-Set myStream = CreateObject("ADODB.Stream")\r
-myStream.Open\r
-myStream.Type = adTypeText\r
-myStream.Charset = "utf-8"\r
-myStream.WriteText "##" & vbLf & _\r
-  "## Bundle of CA Root Certificates" & vbLf & _\r
-  "##" & vbLf & _\r
-  "## Certificate data from Mozilla as of: " & _\r
-    ConvertDateToString(LocalDateToUTC(Now)) & " GMT" & vbLf & _\r
-  "##" & vbLf & _\r
-  "## This is a bundle of X.509 certificates of public Certificate Authorities" & vbLf & _\r
-  "## (CA). These were automatically extracted from Mozilla's root certificates" & vbLf & _\r
-  "## file (certdata.txt).  This file can be found in the mozilla source tree:" & vbLf & _\r
-  "## " & myUrl & vbLf & _\r
-  "##" & vbLf & _\r
-  "## It contains the certificates in PEM format and therefore" & vbLf & _\r
-  "## can be directly used with curl / libcurl / php_curl, or with" & vbLf & _\r
-  "## an Apache+mod_ssl webserver for SSL client authentication." & vbLf & _\r
-  "## Just configure this file as the SSLCACertificateFile." & vbLf & _\r
-  "##" & vbLf & _\r
-  "## Conversion done with mk-ca-bundle.vbs version " & myVersion & "." & vbLf\r
-If (myCdSavF = TRUE) And (myUseOpenSSL = TRUE) Then\r
-  myStream.WriteText "## SHA256: " & FileSHA256(myCdFile) & vbLf\r
-End If\r
-myStream.WriteText "##" & vbLf & vbLf\r
-\r
-myStream.WriteText vbLf\r
-For i = 0 To UBound(myLines)\r
-  If InstrRev(myLines(i), "CKA_LABEL ") Then\r
-    myPattern = "^CKA_LABEL\s+[A-Z0-9]+\s+""(.+?)"""\r
-    myLabel = RegExprFirst(myPattern, myLines(i))\r
-  End If\r
-  If (myInsideCert = TRUE) Then\r
-    If InstrRev(myLines(i), "END") Then\r
-      myInsideCert = FALSE\r
-      While (i < UBound(myLines)) And Not (myLines(i) = "#")\r
-        i = i + 1\r
-        If InstrRev(myLines(i), "CKA_TRUST_SERVER_AUTH CK_TRUST CKT_NSS_TRUSTED_DELEGATOR") Then\r
-          myUntrusted = FALSE\r
-        End If\r
-      Wend\r
-      If (myUntrusted = TRUE) Then\r
-        myNumSkipped = myNumSkipped + 1\r
-      Else\r
-        myStream.WriteText myLabel & vbLf\r
-        myStream.WriteText String(Len(myLabel), "=") & vbLf\r
-        myPem = "-----BEGIN CERTIFICATE-----" & vbLf & _\r
-                Base64Encode(myData) & vbLf & _\r
-                "-----END CERTIFICATE-----" & vbLf\r
-        If (myOptTxt = FALSE) Then\r
-          myStream.WriteText myPem & vbLf\r
-        Else\r
-          Dim myCmd, myRval, myTmpIn, myTmpOut\r
-          myTmpIn = objFSO.GetSpecialFolder(2).Path & "\" & objFSO.GetTempName\r
-          myTmpOut = objFSO.GetSpecialFolder(2).Path & "\" & objFSO.GetTempName\r
-          Set myTmpFh = objFSO.OpenTextFile(myTmpIn, 2, TRUE)\r
-          myTmpFh.Write myPem\r
-          myTmpFh.Close\r
-          myCmd = """" & myOpenSSL & """ x509 -md5 -fingerprint -text " & _\r
-                  "-inform PEM -in " & myTmpIn & " -out " & myTmpOut\r
-          myRval = objShell.Run (myCmd, 0, TRUE)\r
-          objFSO.DeleteFile myTmpIn, TRUE\r
-          If Not (myRval = 0) Then\r
-            MsgBox("Failed to process PEM cert with OpenSSL commandline!"), vbCritical, mySelf\r
-            objFSO.DeleteFile myTmpOut, TRUE\r
-            WScript.Quit 3\r
-          End If\r
-          Set myTmpFh = objFSO.OpenTextFile(myTmpOut, 1)\r
-          myStream.WriteText myTmpFh.ReadAll & vbLf\r
-          myTmpFh.Close\r
-          objFSO.DeleteFile myTmpOut, TRUE\r
-        End If\r
-        myNumCerts = myNumCerts + 1\r
-      End If\r
-    Else\r
-      myOctets = Split(myLines(i), "\")\r
-      For j = 1 To UBound(myOctets)\r
-        myData = myData & Chr(CByte("&o" & myOctets(j)))\r
-      Next\r
-    End If\r
-  End If\r
-  If InstrRev(myLines(i), "CVS_ID ") Then\r
-    myPattern = "^CVS_ID\s+""(.+?)"""\r
-    myRev = RegExprFirst(myPattern, myLines(i))\r
-    myStream.WriteText "# " & myRev & vbLf & vbLf\r
-  End If\r
-  If InstrRev(myLines(i), "CKA_VALUE MULTILINE_OCTAL") Then\r
-    myInsideCert = TRUE\r
-    myUntrusted = TRUE\r
-    myData = ""\r
-  End If\r
-  If InstrRev(myLines(i), "***** BEGIN LICENSE BLOCK *****") Then\r
-    myInsideLicense = TRUE\r
-  End If\r
-  If (myInsideLicense = TRUE) Then\r
-    myStream.WriteText myLines(i) & vbLf\r
-    myLicenseText = myLicenseText & Mid(myLines(i), 2) & vbLf\r
-  End If\r
-  If InstrRev(myLines(i), "***** END LICENSE BLOCK *****") Then\r
-    myInsideLicense = FALSE\r
-    If (myAskLiF = TRUE) Then\r
-      If Not (6 = objShell.PopUp(myLicenseText & vbLf & _\r
-              "Do you agree to the license shown above (required to proceed) ?",, _\r
-              mySelf, vbQuestion + vbYesNo + vbDefaultButton1)) Then\r
-        myStream.Close\r
-        objFSO.DeleteFile myCaFile, TRUE\r
-        WScript.Quit 2\r
-      End If\r
-    End If\r
-  End If\r
-Next\r
-\r
-' To stop the UTF-8 BOM from being written the stream has to be copied and\r
-' then saved as binary.\r
-Dim myCopy\r
-Set myCopy = CreateObject("ADODB.Stream")\r
-myCopy.Type = adTypeBinary\r
-myCopy.Open\r
-myStream.Position = 3 ' Skip UTF-8 BOM\r
-myStream.CopyTo myCopy\r
-myCopy.SaveToFile myCaFile, adSaveCreateOverWrite\r
-myCopy.Close\r
-myStream.Close\r
-Set myCopy = Nothing\r
-Set myStream = Nothing\r
-\r
-' Done\r
-objShell.PopUp "Done (" & myNumCerts & " CA certs processed, " & myNumSkipped & _\r
-               " untrusted skipped).", 20, mySelf, vbInformation\r
-WScript.Quit 0\r
-\r
-Function ConvertBinaryToUTF8(arrBytes)\r
-  Dim objStream\r
-  Set objStream = CreateObject("ADODB.Stream")\r
-  objStream.Open\r
-  objStream.Type = adTypeBinary\r
-  objStream.Write arrBytes\r
-  objStream.Position = 0\r
-  objStream.Type = adTypeText\r
-  objStream.Charset = "utf-8"\r
-  ConvertBinaryToUTF8 = objStream.ReadText\r
-  Set objStream = Nothing\r
-End Function\r
-\r
-Function SaveBinaryData(filename, data)\r
-  Dim objStream\r
-  Set objStream = CreateObject("ADODB.Stream")\r
-  objStream.Type = adTypeBinary\r
-  objStream.Open\r
-  objStream.Write data\r
-  objStream.SaveToFile filename, adSaveCreateOverWrite\r
-  objStream.Close\r
-  Set objStream = Nothing\r
-End Function\r
-\r
-Function RegExprFirst(SearchPattern, TheString)\r
-  Dim objRegExp, Matches                        ' create variables.\r
-  Set objRegExp = New RegExp                    ' create a regular expression.\r
-  objRegExp.Pattern = SearchPattern             ' sets the search pattern.\r
-  objRegExp.IgnoreCase = TRUE                   ' set to ignores case.\r
-  objRegExp.Global = TRUE                       ' set to global search.\r
-  Set Matches = objRegExp.Execute(TheString)    ' do the search.\r
-  If (Matches.Count) Then\r
-    RegExprFirst = Matches(0).SubMatches(0)     ' return first match.\r
-  Else\r
-    RegExprFirst = ""\r
-  End If\r
-  Set objRegExp = Nothing\r
-End Function\r
-\r
-Function Base64Encode(inData)\r
-  Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"\r
-  Dim cOut, sOut, lWrap, I\r
-  lWrap = Int(myWrapLe * 3 / 4)\r
-\r
-  'For each group of 3 bytes\r
-  For I = 1 To Len(inData) Step 3\r
-    Dim nGroup, pOut, sGroup\r
-\r
-    'Create one long from this 3 bytes.\r
-    nGroup = &H10000 * Asc(Mid(inData, I, 1)) + _\r
-             &H100 * MyASC(Mid(inData, I + 1, 1)) + _\r
-             MyASC(Mid(inData, I + 2, 1))\r
-\r
-    'Oct splits the long To 8 groups with 3 bits\r
-    nGroup = Oct(nGroup)\r
-\r
-    'Add leading zeros\r
-    nGroup = String(8 - Len(nGroup), "0") & nGroup\r
-\r
-    'Convert To base64\r
-    pOut = Mid(Base64, CLng("&o" & Mid(nGroup, 1, 2)) + 1, 1) & _\r
-           Mid(Base64, CLng("&o" & Mid(nGroup, 3, 2)) + 1, 1) & _\r
-           Mid(Base64, CLng("&o" & Mid(nGroup, 5, 2)) + 1, 1) & _\r
-           Mid(Base64, CLng("&o" & Mid(nGroup, 7, 2)) + 1, 1)\r
-\r
-    'Add the part To OutPut string\r
-    sOut = sOut + pOut\r
-\r
-    'Add a new line For Each myWrapLe chars In dest\r
-    If (I < Len(inData) - 2) Then\r
-      If (I + 2) Mod lWrap = 0 Then sOut = sOut & vbLf\r
-    End If\r
-  Next\r
-  Select Case Len(inData) Mod 3\r
-    Case 1: '8 bit final\r
-      sOut = Left(sOut, Len(sOut) - 2) & "=="\r
-    Case 2: '16 bit final\r
-      sOut = Left(sOut, Len(sOut) - 1) & "="\r
-  End Select\r
-  Base64Encode = sOut\r
-End Function\r
-\r
-Function MyASC(OneChar)\r
-  If OneChar = "" Then MyASC = 0 Else MyASC = Asc(OneChar)\r
-End Function\r
-\r
-' Return the date in the same format as perl to match mk-ca-bundle.pl output:\r
-' Wed Sep  7 03:12:05 2016\r
-Function ConvertDateToString(input)\r
-  Dim output\r
-  output = WeekDayName(WeekDay(input), TRUE) & " " & _\r
-           MonthName(Month(input), TRUE) & " "\r
-  If (Len(Day(input)) = 1) Then\r
-    output = output & " "\r
-  End If\r
-  output = output & _\r
-           Day(input) & " " & _\r
-           FormatDateTime(input, vbShortTime) & ":"\r
-  If (Len(Second(input)) = 1) Then\r
-    output = output & "0"\r
-  End If\r
-  output = output & _\r
-           Second(input) & " " & _\r
-           Year(input)\r
-  ConvertDateToString = output\r
-End Function\r
-\r
-' Convert local Date to UTC. Microsoft says:\r
-' Use Win32_ComputerSystem CurrentTimeZone property, because it automatically\r
-' adjusts the Time Zone bias for daylight saving time; Win32_Time Zone Bias\r
-' property does not.\r
-' https://msdn.microsoft.com/en-us/library/windows/desktop/ms696015.aspx\r
-Function LocalDateToUTC(localdate)\r
-  Dim item, offset\r
-  For Each item In GetObject("winmgmts:").InstancesOf("Win32_ComputerSystem")\r
-    offset = item.CurrentTimeZone ' the offset in minutes\r
-  Next\r
-  If (offset < 0) Then\r
-    LocalDateToUTC = DateAdd("n",  ABS(offset), localdate)\r
-  Else\r
-    LocalDateToUTC = DateAdd("n", -ABS(offset), localdate)\r
-  End If\r
-  'objShell.PopUp LocalDateToUTC\r
-End Function\r
-\r
-Function FileSHA256(filename)\r
-  Dim cmd, rval, tmpOut, tmpFh\r
-  if (myUseOpenSSL = TRUE) Then\r
-    tmpOut = objFSO.GetSpecialFolder(2).Path & "\" & objFSO.GetTempName\r
-    cmd = """" & myOpenSSL & """ dgst -r -sha256 -out """ & tmpOut & """ """ & filename & """"\r
-    rval = objShell.Run(cmd, 0, TRUE)\r
-    If Not (rval = 0) Then\r
-      MsgBox("Failed to get sha256 of """ & filename & """ with OpenSSL commandline!"), vbCritical, mySelf\r
-      objFSO.DeleteFile tmpOut, TRUE\r
-      WScript.Quit 3\r
-    End If\r
-    Set tmpFh = objFSO.OpenTextFile(tmpOut, 1)\r
-    FileSHA256 = RegExprFirst("^([0-9a-f]{64}) .+", tmpFh.ReadAll)\r
-    tmpFh.Close\r
-    objFSO.DeleteFile tmpOut, TRUE\r
-  Else\r
-    FileSHA256 = ""\r
-  End If\r
-End Function\r