├── .gitattributes
├── .github
├── FUNDING.yml
└── issue_template.md
├── .gitignore
├── CHANGELOG.md
├── LICENSE.txt
├── README.md
├── cipher-suite-black-list.txt
├── sample-config.ini
├── ssl_config.bat
└── testing
├── Test 1 - CLI - No Arguments.bat
├── Test 10 - Script - OS Hosts File Path Corrupt.txt
├── Test 11 - Script - Apache Service Name Error.txt
├── Test 12 - WampServer - Apache Conf Validation Error.txt
├── Test 13 - Script - Restore 1 - Pass.bat
├── Test 14 - Script - Restore 2 - Pass.bat
├── Test 15 - Script - Pass.bat
├── Test 2 - CLI - More Than 2 Arguments.bat
├── Test 3 - CLI - Argument Not Recognised.bat
├── Test 4 - CLI - Must Have Ini Extension.bat
├── Test 5 - CLI - Path Invalid.bat
├── Test 6 - Config - Section Corrupt.bat
├── Test 7 - Config - Key Value Pair Corrupt.bat
├── Test 8 - Config - WampServer Install Path Corrupt.bat
├── Test 9 - Script - Apache Sub path Corrupt.txt
└── configs
├── config-key-value-pair-corrupt.ini
├── config-section-corrupt.ini
├── config-wampserver-install-path-corrupt.ini
└── config.ini
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Set the default behavior, in case people don't have core.autocrlf set.
2 | * text=auto
3 |
4 | # Ensure these specific files always have a CRLF line ending.
5 | *.bat text eol=crlf
6 | *.ini text eol=crlf
7 | *.txt text eol=crlf
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: custom-dev-tools
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
12 | polar: # Replace with a single Polar username
13 | buy_me_a_coffee: customdevtools
14 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
15 |
--------------------------------------------------------------------------------
/.github/issue_template.md:
--------------------------------------------------------------------------------
1 | ## Issue
2 |
3 | Please describe the issue you are having.
4 |
5 | ## Log File Output
6 |
7 | 1. Locate the `ssl_config.log` log file.
8 |
9 | > Default location is: `C:\wamp64 - ssl auto config\logs\ssl_config.log`
10 | >
11 | > Custom base directory location is set on line 10 of your config.ini file.
12 |
13 | 2. Attach the `ssl_config.log` file to this issue.
14 |
15 | ## Environment
16 |
17 | Please provide the following version numbers.
18 | - Microsoft Windows Version:
19 | - WampServer Version:
20 | - WampServer SSL Auto Config Script Version:
21 |
22 | ## Additional Information
23 |
24 | Please add any additional information that may help resolve this issue.
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # PhpStorm IDE workspace file.
2 | .idea/
3 |
4 | # Personal use configuration files.
5 | personal-config.ini
6 | personal-ssl-config.bat
7 | personal-ssl-config-restore.bat
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6 |
7 | ## [Unreleased]
8 |
9 | ## [1.2.3] - 2022-07-11
10 |
11 | ### Updated
12 | - Updated explanation of wampServerExtensionsPath in configuration file and README.md
13 |
14 | ## [1.2.2] - 2022-04-05
15 |
16 | ### Fixed
17 | - Ignore modules_sup folder in bin\apache directory (new to WampServer 3.2.8)
18 |
19 | ## [1.2.1] - 2021-03-11
20 |
21 | ### Added
22 | - Issues template.
23 |
24 | ### Updated
25 | - Updated README.md reflecting minimum Apache version number required for HTTP/2 functionality.
26 |
27 | ## [1.2.0] - 2021-01-24
28 |
29 | ### Added
30 | - Added option to enable HTTP/2 functionality per development domain.
31 |
32 | ## [1.1.1] - 2020-08-25
33 |
34 | ### Fixed
35 | - Added .gitattributes file to normalize EOL's for Windows OS when code is downloaded as ZIP file.
36 |
37 | ## [1.1.0] - 2020-06-22
38 |
39 | ### Added
40 | - Added removal of certificate(s) from Windows store upon 'restore' command.
41 |
42 | ## [1.0.2] - 2020-06-15
43 |
44 | ### Updated
45 | - Moved CLI argument count code (0 & >2) to a more logical section in ssl_config.bat
46 | - Fixed grammatical errors and general formatting in README.md
47 |
48 | ## [1.0.1] - 2020-06-15
49 |
50 | ### Fixed
51 | - Added missing quotes around argument when calling isIniFile.
52 |
53 | ## [1.0.0] - 2020-06-14
54 |
55 | ### Added
56 | - Initial commit.
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Matthew Rath
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WampServer SSL Auto Config
2 |
3 | [](https://github.com/custom-dev-tools/WampServer-SSL-Auto-Config/releases)  [](https://github.com/custom-dev-tools/WampServer-SSL-Auto-Config/stargazers)
4 |
5 | [](https://github.com/custom-dev-tools/WampServer-SSL-Auto-Config/blob/master/LICENSE) [](https://github.com/custom-dev-tools/WampServer-SSL-Auto-Config/commits/master) [](https://github.com/custom-dev-tools/WampServer-SSL-Auto-Config/issues?q=is%3Aopen+is%3Aissue) [](https://github.com/custom-dev-tools/WampServer-SSL-Auto-Config/issues?q=is%3Aissue+is%3Aclosed)
6 |
7 | WampServer SSL Auto Config is a Microsoft Windows batch script designed to automatically generate and configure a fully working Apache SSL / Name Based virtual host development environment with optional HTTP/2 functionality.
8 |
9 | ## Table of Contents
10 |
11 | * [Introduction](#introduction)
12 | * [Minimum Requirements](#minimum-requirements)
13 | * [Compatible Web Browsers](#compatible-web-browsers)
14 | * [Installation](#installation)
15 | * [Configuration](#configuration)
16 | * [WampServer Configuration](#wampserver-configuration)
17 | * [SSL Certificate Details](#ssl-certificate-details)
18 | * [Development Domains](#development-domains)
19 | * [How To Use](#how-to-use)
20 | * [The SSL Config Function](#the-ssl-config-function)
21 | * [The Created Folder Structure](#the-created-folder-structure)
22 | * [The Restore Function](#the-restore-function)
23 | * [Configurable Web Browsers](#configurable-web-browsers)
24 | * [How To Configure Firefox](#how-to-configure-firefox)
25 | * [How To Configure Other Browsers](#how-to-configure-other-browsers)
26 | * [Unable To Modify Your Systems 'Hosts' File](#unable-to-modify-your-systems-hosts-file)
27 |
28 | ## Introduction
29 |
30 | As the web moves towards 100% adaption of SSL, it makes sense that our development environment should match.
31 |
32 | Setting up SSL in WampServer can be a challenge. Knowledge of Apache and OpenSSL is required. The desire to work with multiple domains, each setup with its own unique self-signed SSL certificate, its own unique document root (located in any directory on any drive you want) and its own unique set of log files requires a reliable and repeatable approach.
33 |
34 | In only a couple of seconds, this batch script automatically creates all the necessary domain specific directories, certificates, log files and configuration files, which are then linked to each and every version of Apache you have installed on your system. In addition to this it also adds your SSL certificates to the Windows Trusted Root Certificate Store removing the need to constantly accept untrusted self-signed certificates in the browser. Finally, it also tries to update your systems 'host' file for URL friendly domain name addresses. All of this is achieved through the use of a simple, easy to understand `config.ini` file.
35 |
36 | As a safety measure, running the script for the very first time will back up your systems 'host' file, and the primary configuration file of each and every version of Apache you have installed. Thus, if for any reason things don't go the way they should, a simple `restore` command can roll back WampServer to its prior state.
37 |
38 | ## Minimum Requirements
39 |
40 | The following are required for the SSL Auto Config script to function correctly.
41 |
42 | * Microsoft Windows 7 and up.
43 | * WampServer v3.0.0 and up.
44 | * Use of Apache 2.4 and up.
45 | * Use of Apache 2.4.17 and up when using HTTP/2.
46 | * Use of Apache as a service.
47 | * Administrator rights.
48 |
49 | Administrator rights are required to update and roll back your systems 'host' file. Without Administrator rights this script will not be able to write to your systems 'host' file, preventing you from using URL friendly domain name addresses. Whilst this does not stop the script from working, it definitely does prevent the use of this great feature.
50 |
51 | ## Compatible Web Browsers
52 |
53 | Whilst any browser should work, browsers that use the Windows Trusted Root Certificate Store can take advantage of the trusted self-signed certificates.
54 |
55 | Such browsers are:
56 |
57 | * Chrome
58 | * Internet Explorer
59 | * Edge
60 | * Opera
61 |
62 | For browsers that do not use the Windows Trusted Root Certificate Store (such as Firefox), see the section titled [Configurable Web Browsers](#configurable-web-browsers).
63 |
64 | ## Installation
65 |
66 | No installation is required.
67 |
68 | At 51kB the SSL Auto Config script is small enough to be saved anywhere in your file system.
69 |
70 | ## Configuration
71 |
72 | Configuration is carried out by editing a simple, easy to understand config `.ini` file.
73 |
74 | Below are the contents of the `sample-config.ini` file.
75 |
76 | ````ini
77 | ;--------------------------;
78 | ; WampServer Configuration ;
79 | ;--------------------------;
80 |
81 | ; Your WampServer installation path.
82 | wampServerInstallPath=C:\wamp64
83 |
84 | ; Your custom path to store your SSL certificates, keys, logs and vhost files.
85 | ; Ensure this path is NOT within your WampServer installation path.
86 | wampServerExtensionsPath=C:\wamp64 - ssl auto config
87 |
88 | ;-------------------------;
89 | ; SSL Certificate Details ;
90 | ;-------------------------;
91 |
92 | ; These (common) ssl certificate details are used to build each developments domain name certificate.
93 | ;
94 | ; sslCity: The full name of a city.
95 | ; sslState: The full name of a state.
96 | ; sslCountry: The two letter ISO code of a country.
97 | ; sslOrganisation: The organisation name.
98 | ; sslOrganisationUnit: The unit name of a organisation.
99 | ; sslEmail: Use the 'local' part of an email address followed by the @ (at) symbol only.
100 | ; IMPORTANT: Do not include the 'domain' part of the email address as the hostname will be auto-appended.
101 | ; sslDays: The number of days you would like the certificates to remain valid for.
102 |
103 | sslCity=Brisbane
104 | sslState=Queensland
105 | sslCountry=AU
106 | sslOrganization=Business
107 | sslOrganizationUnit=IT Department
108 | sslEmail=webmaster@
109 | sslDays=3650
110 |
111 | ;---------------------;
112 | ; Development Domains ;
113 | ;---------------------;
114 |
115 | [Website 1]
116 | hostname=www.dev.website-1.com.au
117 | documentRoot=C:/wamp64 - domains/website-1/public_html
118 | http2=true
119 |
120 | [Website 2]
121 | hostname=www.dev.website-2.com.au
122 | documentRoot=C:/wamp64 - domains/website-2/public_html
123 | http2=true
124 | ````
125 |
126 | #### WampServer Configuration
127 |
128 | * `wampServerInstallPath` : This value represents your WampServers (absolute) installation path.
129 |
130 | > The default WampServer installation directories are:
131 | > * `C:\wamp` - For 32-bit installations.
132 | > * `C:\wamp64` - For 64-bit installations.
133 |
134 | * `wampServerExtensionsPath` : This value represents your (absolute) custom path that will hold all the certificates, keys, log and vhost files used by WampServer. This path will be created if it does not already exist. This path should NOT be within the WampServer installation path. Whilst it can be in any other path on the same or different drive, it is not recommended to point this to a network drive.
135 |
136 | #### SSL Certificate Details
137 |
138 | * `sslCity` : This value represents the full name of a city.
139 |
140 | * `sslState` : This value represents the full name of a state.
141 |
142 | * `sslCountry` : This value represents the two-letter ISO code of a country.
143 |
144 | * `sslOrganisation` : This value represents an organisation name.
145 |
146 | * `sslOrganisationUnit` : This value represents the unit name of an organisation.
147 |
148 | * `sslEmail` : This value represents the email address of the organisation.
149 |
150 | > **Note:** Use the 'local' part of an email address followed by the @ (at) symbol only. Do not include the 'domain' part of the email address as the hostname will be auto-appended.
151 |
152 | * `sslDays` : This value represents the number of days you would like the certificates to remain valid for. Enter a high value, so your SSL certificate does not expire to regularly and become an inconvenience.
153 |
154 | #### Development Domains
155 |
156 | * `[Website 1]` : This section name represent the human-readable host name which is used within your various configuration files. Whilst it is not used by WampServer itself, it will definitely make identification within the generated configuration files easier.
157 |
158 | * `hostname` : This value represents the URL friendly address used to access your site in your web browser.
159 |
160 | * `documentRoot` : This value represents the (absolute) path to the public facing directory (commonly called the document root) of your website. This path does not need to be in the same directory or even on the same drive as WampServer. That said, it is not recommended to point this to a network drive.
161 |
162 | * `http2` : This boolean value (`true` or `false`) represents the respective enabling or disabling of HTTP/2 functionality.
163 |
164 | > **Note 1:** HTTP/2 is only available from Apache 2.4.17 and later.
165 | >
166 | > **Note 2:** You may need to clear (or disable) your browser cache when toggling between HTTP/1.1 and HTTP/2.
167 |
168 | > **IMPORTANT:** Do not add quotation marks around your values, even if they contain spaces.
169 |
170 | Blank lines and commented lines starting with a semicolon ( ; ) character are ignored. You may format and comment your configuration file any way you like.
171 |
172 | > **Tip:** You can copy and rename the `sample-config.ini` file to any directory on any drive you like.
173 |
174 | ## How To Use
175 |
176 | The SSL Auto Config script can perform two functions.
177 |
178 | 1. Configure each and every installed version of Apache to use SSL.
179 | 2. Return each and every installed version of Apache back to its original state.
180 |
181 | ### The SSL Config Function
182 |
183 | To run the script from a CMD prompt:
184 |
185 | ````shell
186 | C:\>: "C:\path\to\ssl_config.bat" "C:\path\to\my\config.ini"
187 | ````
188 |
189 | To run the script from a Bash or PowerShell prompt:
190 |
191 | ````shell
192 | $ start "C:\path\to\ssl_config.bat" "C:\path\to\config.ini"
193 | ````
194 |
195 | > **Note:** Don't forget to enclose paths in quotes if they contain spaces.
196 |
197 | Running the script performs the following:
198 |
199 | 1. Parses the config file to get required data.
200 | 2. Validates your currently installed versions of Apache configuration files prior to modifying them.
201 | 3. Backs up your systems 'host' file and each installed version of Apache's primary configuration file.
202 | 4. Creates the `wampServerExtensionsPath` folder structure.
203 | 5. Loops through the domains creating domain specific folders, Apache config files, SSL certificates, adds the SSL certificates to the Windows Store and updates your systems 'hosts' file.
204 | 6. Links the domain specific Apache configuration files to each installed version of Apache's primary configuration file whilst also enabling SSL.
205 | 7. Re-validates the Apache configuration files to ensure no errors were introduced.
206 | 8. Flush the DNS and restart the Apache service.
207 |
208 | > If your systems 'hosts' file was unable to be updated then see the section titled [Unable To Modify Your Systems 'Hosts' File](#unable-to-modify-your-systems-hosts-file).
209 |
210 | Once the script has run, any open web browsers will need to be refreshed for the changes to take effect.
211 |
212 | If at any stage you install a new version of Apache just run the script again to allow its primary configuration file to be linked and SSL enabled.
213 |
214 | If you find your SSL certificate(s) expired then just run the script again. Doing so will generate new certificates and update then in the Windows Trusted Root Certificate store. If your certificate(s) seem to expire to quickly, just increase the value of `sslDays` in your `config.ini` file.
215 |
216 | > **IMPORTANT:** It is important to understand that the backup taken of each installed version of Apache's primary configuration file is a 'snapshot' of their state at that particular point in time. Any changes you make to that version of Apache (such as enabling or disabling modules via the WampServer menu located in the notification area) will not be saved to the backed-up version. Therefore, if you run the `restore` command, the 'backed-up' version will overwrite any modified settings.
217 |
218 | #### The Created Folder Structure
219 |
220 | This script generates a pre-set folder structure base around the value of `wampServerExtensionsPath` in your `config.ini` file.
221 |
222 | If you were to use the `sample-config.ini` file as your configuration file then the following command
223 |
224 | ````shell
225 | C:\>: "C:\path\to\ssl_config.bat" "C:\path\to\sample-config.ini"
226 | ````
227 |
228 | would generate the below folder structure.
229 |
230 | ```
231 | C:\wamp64 - ssl auto config
232 | ├─ certs
233 | │ ├─ www.dev.website-1.com.au
234 | │ │ ├─ openssl.cnf
235 | │ │ ├─ private.key
236 | │ │ └─ server.crt
237 | │ └─ www.dev.website-2.com.au
238 | │ ├─ openssl.cnf
239 | │ ├─ private.key
240 | │ └─ server.crt
241 | ├─ logs
242 | │ ├─ www.dev.website-1.com.au
243 | │ │ ├─ access.log
244 | │ │ ├─ error.log
245 | │ │ └─ ssl_request.log
246 | │ ├─ www.dev.website-2.com.au
247 | │ │ ├─ access.log
248 | │ │ ├─ error.log
249 | │ │ └─ ssl_request.log
250 | │ └─ ssl_config.log
251 | └─ vhosts
252 | ├─ http
253 | │ ├─ www.dev.website-1.com.au.conf
254 | │ └─ www.dev.website-2.com.au.conf
255 | └─ https
256 | ├─ conf
257 | │ └─ httpd-ssl.conf
258 | ├─ www.dev.website-1.com.au.conf
259 | └─ www.dev.website-2.com.au.conf
260 | ```
261 |
262 | This folder structure will remain the same, even after multiple runs **unless** you change the value of `wampServerExtensionsPath` in your `config.ini` file.
263 |
264 | Adding a development domain to your `config.ini` file will add it to this folder structure.
265 |
266 | Removing a development domain from your `config.ini` file will not remove it from this folder structure. You must remove the specific folder and files manually if you no longer want them.
267 |
268 | The folder(s) you keep your website(s) code in is not touched at all by this script.
269 |
270 | > **Note:** As a record of configuration and to assist in any fault-finding, the log file `ssl_config.log` found under the `logs` folder records in detail the scripts actions taken in configuring WampServers SSL. Please be aware this log file is appended on each run of the script, so over many runs it may grow to a considerable size.
271 |
272 | ### The Restore Function
273 |
274 | To run the script from a CMD prompt:
275 |
276 | ````shell
277 | C:\>: "C:\path\to\ssl_config.bat" "C:\path\to\my\config.ini" restore
278 | ````
279 |
280 | To run the script from a Bash or PowerShell prompt:
281 |
282 | ````shell
283 | $ start "C:\path\to\ssl_config.bat" "C:\path\to\config.ini" restore
284 | ````
285 |
286 | > **Note:** Don't forget to enclose paths in quotes if they contain spaces.
287 |
288 | Running the script performs the following:
289 |
290 | 1. Parses the config file to get required data.
291 | 2. Restores each and every installed version of Apache's primary configuration file (if a backup is found).
292 | 3. Removes each and every config domain name from the Windows Trusted Root Certificate Store.
293 | 4. Tries to restore the systems 'hosts' file (if a backup is found).
294 |
295 | > If your systems 'hosts' file was unable to be restored then see the section titled [Unable To Modify Your Systems 'Hosts' File](#unable-to-modify-your-systems-hosts-file).
296 |
297 | If Apache fails to restart following the `restore` command then you will need to perform a manual update as indicated below.
298 |
299 | 1. In each and every version of Apache you have installed:
300 | 1. Delete the file `C:\wamp64\bin\apache\apacheX.X.XX\conf\httpd.conf`.
301 | 2. Rename the file `C:\wamp64\bin\apache\apacheX.X.XX\conf\httpd-backup.conf` to `httpd.conf`.
302 | 2. In the directory containing your system 'hosts' file:
303 | 1. Delete the file `%systemroot%\System32\drivers\etc\hosts`.
304 | 2. Rename the file `%systemroot%\System32\drivers\etc\hosts-backup` to `host`.
305 |
306 | > **Note:** You will need Administrator rights to perform the above 'hosts' file action.
307 |
308 | ## Configurable Web Browsers
309 |
310 | Not all browsers use the Windows Trusted Root Certificate Store. For those that don't, some configuration may be required.
311 |
312 | #### How To Configure Firefox
313 |
314 | By default, Firefox prefers to use its own internal certificate store. To enable its use of the Windows Trusted Root Certificate Store you must first enable this feature.
315 |
316 | To enable this feature, follow the below steps:
317 | 1. In the address bar type `about:config` and press the return key.
318 | 2. If prompted, click the 'Accept the Risk and Continue' and 'Show All' buttons.
319 | 3. In the 'Search preference name' field type `security.enterprise_roots.enabled` into the search field.
320 | 4. If the flag is missing, select `boolean` as a value type and then click the add ( + ) button.
321 | 5. If the flag exists and its value is `true` then Firefox is configured correctly.
322 |
323 | #### How To Configure Other Browsers
324 |
325 | If you know of any other browser(s) that would benefit by being added to this list then please do let me know.
326 |
327 | ## Unable To Modify Your Systems 'Hosts' File
328 |
329 | If you are unable to update or restore your systems 'hosts' file then:
330 |
331 | 1. You are not logged in as an Administrator. To change this either login as an Administrator or right-click the script and select 'Run as administrator'.
332 | 2. Your Anti-Virus software is stopping the modification of your systems files, including your systems 'hosts' file. This is usually a standard function of Anti-Virus software, and the most probable cause of this issue. To change this turn off / disable your Anti-Virus software, run the script and then turn on / enable your Anti-Virus software. Most Anti-Virus software has an easily accessible option to disable protection for a short period of time. EG: 1-minute, 3-minutes, etc. You should only need to disable it for 1-minute for the script to execute correctly.
--------------------------------------------------------------------------------
/cipher-suite-black-list.txt:
--------------------------------------------------------------------------------
1 | Ref 1: https://en.wikipedia.org/wiki/HTTP/2
2 | Ref 2: https://http2.github.io/http2-spec/#BadCipherSuites
3 |
4 | TLS_NULL_WITH_NULL_NULL
5 | TLS_RSA_WITH_NULL_MD5
6 | TLS_RSA_WITH_NULL_SHA
7 | TLS_RSA_EXPORT_WITH_RC4_40_MD5
8 | TLS_RSA_WITH_RC4_128_MD5
9 | TLS_RSA_WITH_RC4_128_SHA
10 | TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5
11 | TLS_RSA_WITH_IDEA_CBC_SHA
12 | TLS_RSA_EXPORT_WITH_DES40_CBC_SHA
13 | TLS_RSA_WITH_DES_CBC_SHA
14 | TLS_RSA_WITH_3DES_EDE_CBC_SHA
15 | TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA
16 | TLS_DH_DSS_WITH_DES_CBC_SHA
17 | TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA
18 | TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA
19 | TLS_DH_RSA_WITH_DES_CBC_SHA
20 | TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA
21 | TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
22 | TLS_DHE_DSS_WITH_DES_CBC_SHA
23 | TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA
24 | TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
25 | TLS_DHE_RSA_WITH_DES_CBC_SHA
26 | TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
27 | TLS_DH_anon_EXPORT_WITH_RC4_40_MD5
28 | TLS_DH_anon_WITH_RC4_128_MD5
29 | TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA
30 | TLS_DH_anon_WITH_DES_CBC_SHA
31 | TLS_DH_anon_WITH_3DES_EDE_CBC_SHA
32 | TLS_KRB5_WITH_DES_CBC_SHA
33 | TLS_KRB5_WITH_3DES_EDE_CBC_SHA
34 | TLS_KRB5_WITH_RC4_128_SHA
35 | TLS_KRB5_WITH_IDEA_CBC_SHA
36 | TLS_KRB5_WITH_DES_CBC_MD5
37 | TLS_KRB5_WITH_3DES_EDE_CBC_MD5
38 | TLS_KRB5_WITH_RC4_128_MD5
39 | TLS_KRB5_WITH_IDEA_CBC_MD5
40 | TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA
41 | TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA
42 | TLS_KRB5_EXPORT_WITH_RC4_40_SHA
43 | TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5
44 | TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5
45 | TLS_KRB5_EXPORT_WITH_RC4_40_MD5
46 | TLS_PSK_WITH_NULL_SHA
47 | TLS_DHE_PSK_WITH_NULL_SHA
48 | TLS_RSA_PSK_WITH_NULL_SHA
49 | TLS_RSA_WITH_AES_128_CBC_SHA
50 | TLS_DH_DSS_WITH_AES_128_CBC_SHA
51 | TLS_DH_RSA_WITH_AES_128_CBC_SHA
52 | TLS_DHE_DSS_WITH_AES_128_CBC_SHA
53 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA
54 | TLS_DH_anon_WITH_AES_128_CBC_SHA
55 | TLS_RSA_WITH_AES_256_CBC_SHA
56 | TLS_DH_DSS_WITH_AES_256_CBC_SHA
57 | TLS_DH_RSA_WITH_AES_256_CBC_SHA
58 | TLS_DHE_DSS_WITH_AES_256_CBC_SHA
59 | TLS_DHE_RSA_WITH_AES_256_CBC_SHA
60 | TLS_DH_anon_WITH_AES_256_CBC_SHA
61 | TLS_RSA_WITH_NULL_SHA256
62 | TLS_RSA_WITH_AES_128_CBC_SHA256
63 | TLS_RSA_WITH_AES_256_CBC_SHA256
64 | TLS_DH_DSS_WITH_AES_128_CBC_SHA256
65 | TLS_DH_RSA_WITH_AES_128_CBC_SHA256
66 | TLS_DHE_DSS_WITH_AES_128_CBC_SHA256
67 | TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
68 | TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA
69 | TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA
70 | TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA
71 | TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA
72 | TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA
73 | TLS_DHE_RSA_WITH_AES_128_CBC_SHA256
74 | TLS_DH_DSS_WITH_AES_256_CBC_SHA256
75 | TLS_DH_RSA_WITH_AES_256_CBC_SHA256
76 | TLS_DHE_DSS_WITH_AES_256_CBC_SHA256
77 | TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
78 | TLS_DH_anon_WITH_AES_128_CBC_SHA256
79 | TLS_DH_anon_WITH_AES_256_CBC_SHA256
80 | TLS_RSA_WITH_CAMELLIA_256_CBC_SHA
81 | TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA
82 | TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA
83 | TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA
84 | TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA
85 | TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA
86 | TLS_PSK_WITH_RC4_128_SHA
87 | TLS_PSK_WITH_3DES_EDE_CBC_SHA
88 | TLS_PSK_WITH_AES_128_CBC_SHA
89 | TLS_PSK_WITH_AES_256_CBC_SHA
90 | TLS_DHE_PSK_WITH_RC4_128_SHA
91 | TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA
92 | TLS_DHE_PSK_WITH_AES_128_CBC_SHA
93 | TLS_DHE_PSK_WITH_AES_256_CBC_SHA
94 | TLS_RSA_PSK_WITH_RC4_128_SHA
95 | TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA
96 | TLS_RSA_PSK_WITH_AES_128_CBC_SHA
97 | TLS_RSA_PSK_WITH_AES_256_CBC_SHA
98 | TLS_RSA_WITH_SEED_CBC_SHA
99 | TLS_DH_DSS_WITH_SEED_CBC_SHA
100 | TLS_DH_RSA_WITH_SEED_CBC_SHA
101 | TLS_DHE_DSS_WITH_SEED_CBC_SHA
102 | TLS_DHE_RSA_WITH_SEED_CBC_SHA
103 | TLS_DH_anon_WITH_SEED_CBC_SHA
104 | TLS_RSA_WITH_AES_128_GCM_SHA256
105 | TLS_RSA_WITH_AES_256_GCM_SHA384
106 | TLS_DH_RSA_WITH_AES_128_GCM_SHA256
107 | TLS_DH_RSA_WITH_AES_256_GCM_SHA384
108 | TLS_DH_DSS_WITH_AES_128_GCM_SHA256
109 | TLS_DH_DSS_WITH_AES_256_GCM_SHA384
110 | TLS_DH_anon_WITH_AES_128_GCM_SHA256
111 | TLS_DH_anon_WITH_AES_256_GCM_SHA384
112 | TLS_PSK_WITH_AES_128_GCM_SHA256
113 | TLS_PSK_WITH_AES_256_GCM_SHA384
114 | TLS_RSA_PSK_WITH_AES_128_GCM_SHA256
115 | TLS_RSA_PSK_WITH_AES_256_GCM_SHA384
116 | TLS_PSK_WITH_AES_128_CBC_SHA256
117 | TLS_PSK_WITH_AES_256_CBC_SHA384
118 | TLS_PSK_WITH_NULL_SHA256
119 | TLS_PSK_WITH_NULL_SHA384
120 | TLS_DHE_PSK_WITH_AES_128_CBC_SHA256
121 | TLS_DHE_PSK_WITH_AES_256_CBC_SHA384
122 | TLS_DHE_PSK_WITH_NULL_SHA256
123 | TLS_DHE_PSK_WITH_NULL_SHA384
124 | TLS_RSA_PSK_WITH_AES_128_CBC_SHA256
125 | TLS_RSA_PSK_WITH_AES_256_CBC_SHA384
126 | TLS_RSA_PSK_WITH_NULL_SHA256
127 | TLS_RSA_PSK_WITH_NULL_SHA384
128 | TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256
129 | TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256
130 | TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256
131 | TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256
132 | TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
133 | TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256
134 | TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256
135 | TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256
136 | TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256
137 | TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256
138 | TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256
139 | TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256
140 | TLS_EMPTY_RENEGOTIATION_INFO_SCSV
141 | TLS_ECDH_ECDSA_WITH_NULL_SHA
142 | TLS_ECDH_ECDSA_WITH_RC4_128_SHA
143 | TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA
144 | TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA
145 | TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA
146 | TLS_ECDHE_ECDSA_WITH_NULL_SHA
147 | TLS_ECDHE_ECDSA_WITH_RC4_128_SHA
148 | TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA
149 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA
150 | TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA
151 | TLS_ECDH_RSA_WITH_NULL_SHA
152 | TLS_ECDH_RSA_WITH_RC4_128_SHA
153 | TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA
154 | TLS_ECDH_RSA_WITH_AES_128_CBC_SHA
155 | TLS_ECDH_RSA_WITH_AES_256_CBC_SHA
156 | TLS_ECDHE_RSA_WITH_NULL_SHA
157 | TLS_ECDHE_RSA_WITH_RC4_128_SHA
158 | TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
159 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA
160 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA
161 | TLS_ECDH_anon_WITH_NULL_SHA
162 | TLS_ECDH_anon_WITH_RC4_128_SHA
163 | TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA
164 | TLS_ECDH_anon_WITH_AES_128_CBC_SHA
165 | TLS_ECDH_anon_WITH_AES_256_CBC_SHA
166 | TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA
167 | TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA
168 | TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA
169 | TLS_SRP_SHA_WITH_AES_128_CBC_SHA
170 | TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA
171 | TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA
172 | TLS_SRP_SHA_WITH_AES_256_CBC_SHA
173 | TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA
174 | TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA
175 | TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256
176 | TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384
177 | TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256
178 | TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384
179 | TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
180 | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384
181 | TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256
182 | TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384
183 | TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256
184 | TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384
185 | TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256
186 | TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384
187 | TLS_ECDHE_PSK_WITH_RC4_128_SHA
188 | TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA
189 | TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA
190 | TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA
191 | TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256
192 | TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384
193 | TLS_ECDHE_PSK_WITH_NULL_SHA
194 | TLS_ECDHE_PSK_WITH_NULL_SHA256
195 | TLS_ECDHE_PSK_WITH_NULL_SHA384
196 | TLS_RSA_WITH_ARIA_128_CBC_SHA256
197 | TLS_RSA_WITH_ARIA_256_CBC_SHA384
198 | TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256
199 | TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384
200 | TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256
201 | TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384
202 | TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256
203 | TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384
204 | TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256
205 | TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384
206 | TLS_DH_anon_WITH_ARIA_128_CBC_SHA256
207 | TLS_DH_anon_WITH_ARIA_256_CBC_SHA384
208 | TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256
209 | TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384
210 | TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256
211 | TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384
212 | TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256
213 | TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384
214 | TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256
215 | TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384
216 | TLS_RSA_WITH_ARIA_128_GCM_SHA256
217 | TLS_RSA_WITH_ARIA_256_GCM_SHA384
218 | TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256
219 | TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384
220 | TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256
221 | TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384
222 | TLS_DH_anon_WITH_ARIA_128_GCM_SHA256
223 | TLS_DH_anon_WITH_ARIA_256_GCM_SHA384
224 | TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256
225 | TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384
226 | TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256
227 | TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384
228 | TLS_PSK_WITH_ARIA_128_CBC_SHA256
229 | TLS_PSK_WITH_ARIA_256_CBC_SHA384
230 | TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256
231 | TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384
232 | TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256
233 | TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384
234 | TLS_PSK_WITH_ARIA_128_GCM_SHA256
235 | TLS_PSK_WITH_ARIA_256_GCM_SHA384
236 | TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256
237 | TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384
238 | TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256
239 | TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384
240 | TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256
241 | TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384
242 | TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256
243 | TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384
244 | TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256
245 | TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384
246 | TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256
247 | TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384
248 | TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256
249 | TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384
250 | TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256
251 | TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384
252 | TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256
253 | TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384
254 | TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256
255 | TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384
256 | TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256
257 | TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384
258 | TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256
259 | TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384
260 | TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256
261 | TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384
262 | TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256
263 | TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384
264 | TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256
265 | TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384
266 | TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256
267 | TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384
268 | TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256
269 | TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384
270 | TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256
271 | TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384
272 | TLS_RSA_WITH_AES_128_CCM
273 | TLS_RSA_WITH_AES_256_CCM
274 | TLS_RSA_WITH_AES_128_CCM_8
275 | TLS_RSA_WITH_AES_256_CCM_8
276 | TLS_PSK_WITH_AES_128_CCM
277 | TLS_PSK_WITH_AES_256_CCM
278 | TLS_PSK_WITH_AES_128_CCM_8
279 | TLS_PSK_WITH_AES_256_CCM_8
--------------------------------------------------------------------------------
/sample-config.ini:
--------------------------------------------------------------------------------
1 | ;--------------------------;
2 | ; WampServer Configuration ;
3 | ;--------------------------;
4 |
5 | ; Your WampServer installation path.
6 | wampServerInstallPath=C:\wamp64
7 |
8 | ; Your custom path to store your SSL certificates, keys, logs and vhost files.
9 | ; Ensure this path is NOT within your WampServer installation path.
10 | wampServerExtensionsPath=C:\wamp64 - ssl auto config
11 |
12 | ;-------------------------;
13 | ; SSL Certificate Details ;
14 | ;-------------------------;
15 |
16 | ; These (common) ssl certificate details are used to build each developments domain name certificate.
17 | ;
18 | ; sslCity: The full name of a city.
19 | ; sslState: The full name of a state.
20 | ; sslCountry: The two letter ISO code of a country.
21 | ; sslOrganisation: The organisation name.
22 | ; sslOrganisationUnit: The unit name of a organisation.
23 | ; sslEmail: Use the 'local' part of an email address followed by the @ (at) symbol only.
24 | ; IMPORTANT: Do not include the 'domain' part of the email address as the hostname will be auto-appended.
25 | ; sslDays: The number of days you would like the certificates to remain valid for.
26 |
27 | sslCity=Brisbane
28 | sslState=Queensland
29 | sslCountry=AU
30 | sslOrganization=Business
31 | sslOrganizationUnit=IT Department
32 | sslEmail=webmaster@
33 | sslDays=3650
34 |
35 | ;---------------------;
36 | ; Development Domains ;
37 | ;---------------------;
38 |
39 | [Website 1]
40 | hostname=www.dev.website-1.com.au
41 | documentRoot=C:/wamp64 - domains/website-1/public_html
42 | http2=true
43 |
44 | [Website 2]
45 | hostname=www.dev.website-2.com.au
46 | documentRoot=C:/wamp64 - domains/website-2/public_html
47 | http2=true
--------------------------------------------------------------------------------
/ssl_config.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | cls
3 | setlocal EnableExtensions EnableDelayedExpansion
4 |
5 | rem -----------------------
6 | rem INITIALISATION
7 | rem -----------------------
8 | rem Set default variables
9 | rem -----------------------
10 | set $scriptVersion=1.2.3
11 | set $scriptLogFileName=ssl_config.log
12 |
13 | rem WampServer sub-paths.
14 | set $subPathToApacheFolders=bin\apache
15 |
16 | rem WampServer Apache sub-paths.
17 | set $subPathToApacheHttpdExe=bin\httpd.exe
18 | set $subPathToApacheOpenSslExe=bin\openssl.exe
19 |
20 | rem Operating system paths.
21 | set $pathToOSHostsFile=%systemroot%\System32\drivers\etc\hosts
22 | set $pathToUsersTempFile=%temp%\ssl_config_temp_file.txt
23 |
24 |
25 | rem -------------------
26 | rem Get computer name
27 | rem -------------------
28 | set $computerName=%ComputerName%
29 |
30 |
31 | rem ----------------
32 | rem Get IP address
33 | rem ----------------
34 | for /f "tokens=2 delims=[]" %%a in ('ping %ComputerName% -4 -n 1') do set $ipAddress=%%a
35 |
36 |
37 | rem ---------------------
38 | rem Get IP network part
39 | rem ---------------------
40 | for /f "tokens=1,2 delims=." %%a in ("%$ipAddress%") do set $ipNetworkPart=%%a.%%b
41 |
42 |
43 | rem ----------------------
44 | rem Set echo offset hack
45 | rem ----------------------
46 |
47 | rem Hack to define a backspace so the 'set /p' command can be offset from the windows edge.
48 | for /f %%a in ('"prompt $H &echo on &for %%b in (1) do rem"') do set backspace=%%a
49 |
50 |
51 | rem ------------------
52 | rem Set window title
53 | rem ------------------
54 | title WampServer SSL Auto Config (v%$scriptVersion%)
55 |
56 |
57 | rem -------------
58 | rem Show header
59 | rem -------------
60 | echo:
61 | echo WampServer SSL Auto Config (v%$scriptVersion%)
62 | echo -----------------------------------
63 | echo:
64 |
65 | rem -------------------
66 | rem CLI
67 | rem -------------------
68 | rem Get CLI arg count
69 | rem -------------------
70 |
71 | rem Count the number of arguments.
72 | set $argumentCount=0
73 | for %%x in (%*) do Set /A $argumentCount+=1
74 |
75 | rem Check if no arguments were given.
76 | if !$argumentCount! equ 0 (
77 | call :failure "CLI Argument Error" "ssl_conf.bat" "No ini file was given." "Please pass in the path to your config.ini file."
78 | )
79 |
80 | rem Check if more than two arguments were given.
81 | if !$argumentCount! gtr 2 (
82 | call :failure "CLI Argument Error" "ssl_conf.bat" "More than two arguments were given." "Please only pass in a maximum of 2 arguments, your ini file and the optional restore command."
83 | )
84 |
85 |
86 | rem ----------------
87 | rem Get CLI arg(s)
88 | rem ----------------
89 |
90 | rem Set the variables.
91 | set $configPath=
92 | set $restoreFlag=false
93 |
94 | rem Check if two arguments were given.
95 | if !$argumentCount! equ 2 (
96 | rem Check for first combination.
97 | if /i "%1" equ "restore" (
98 | set $restoreFlag=true
99 | set $configPath=%~f2
100 | ) else (
101 | rem Check for second combination.
102 | if /i "%2" equ "restore" (
103 | set $restoreFlag=true
104 | set $configPath=%~f1
105 | ) else (
106 | rem CLI command not recognised.
107 | call :failure "CLI Argument Error" "ssl_conf.bat" "Argument not recognised."
108 | )
109 | )
110 | )
111 |
112 | rem Check if one argument was given.
113 | if !$argumentCount! equ 1 (
114 | set $configPath=%~f1
115 | )
116 |
117 |
118 | rem -------------------------------------------
119 | rem Check CLI config arg has '.ini' extension
120 | rem -------------------------------------------
121 |
122 | rem Check if the file is an .ini file.
123 | call :isIniFile "!$configPath!"
124 |
125 | rem Check the result.
126 | if /i "!$result!" equ "false" (
127 | rem Config file name does not contain a valid extension (.ini)
128 | call :failure "CLI Argument Error" "ssl_conf.bat" "Your config file must have a .ini extension."
129 | )
130 |
131 |
132 | rem --------------------------
133 | rem CONFIG FILE
134 | rem --------------------------
135 | rem Check config file exists
136 | rem --------------------------
137 |
138 | rem Check that the configuration file path exists.
139 | if not exist "%$configPath%" (
140 | call :failure "CLI Argument Error" "ssl_conf.bat" "Path to ^"!$configPath!^" does not exist."
141 | )
142 |
143 |
144 | rem -------------------
145 | rem Parse config file
146 | rem -------------------
147 |
148 | rem Set the default variables.
149 | set $inSection=false
150 | set $totalConfigDomains=0
151 |
152 | rem Parse the configuration file line by line, skipping (by default) all blank lines and lines starting with a semicolon.
153 | for /F "usebackq delims=" %%a in ("!$configPath!") do (
154 | rem Set the variables.
155 | set $line=%%a
156 |
157 | rem Check for a section.
158 | if "!$line:~0,1!" == "[" (
159 | if "!$line:~-1!" == "]" (
160 | set $inSection=true
161 | set /A $totalConfigDomains=$totalConfigDomains+1
162 | set $key=name
163 | set $value=!$line:~1,-1!
164 | ) else (
165 | call :failure "Config File Error" "!$configPath!" "!$line!" "A [Section] name must not contain any trailing characters."
166 | )
167 | ) else (
168 | rem Split the line around the '=' sign (assuming one exists).
169 | for /F "tokens=1,2 delims==" %%b in ("!$line!") do (
170 | rem Check for a valid key / value pair.
171 | if not "%%b%%c" == "%%c%%b" (
172 | set $key=%%b
173 | set $value=%%c
174 | ) else (
175 | call :failure "Config File Error" "!$configPath!" "^"!$line!^" key or value missing."
176 | )
177 | )
178 | )
179 |
180 | rem Build the config array.
181 | if "!$inSection!" == "false" (
182 | set $config[!$key!]=!$value!
183 | ) else (
184 | set $config[!$totalConfigDomains!][!$key!]=!$value!
185 | )
186 | )
187 |
188 | call :logToScreen "Parsed configuration file."
189 |
190 |
191 | rem ---------------------
192 | rem Initialise log path
193 | rem ---------------------
194 |
195 | rem Create the log path if it does not exist.
196 | if not exist "%$config[wampServerExtensionsPath]%\logs" (
197 | md "%$config[wampServerExtensionsPath]%\logs"
198 | call :logToScreen "Created common 'logs' directory."
199 | ) else (
200 | call :logToScreen "Common 'logs' directory already exists."
201 | )
202 |
203 | rem Set the log file path.
204 | set $logFilePath=!$config[wampServerExtensionsPath]!\logs\!$scriptLogFileName!
205 |
206 | rem Write header to log file.
207 | (
208 | echo:
209 | echo ===========================================================
210 | echo:
211 | echo !date! : WampServer SSL Auto Config Script ^(v%$scriptVersion%^)
212 | echo:
213 | ) >> "!$logFilePath!"
214 |
215 | call :logToBoth "Script initialised."
216 | call :logToBoth "---------------------------------------------"
217 |
218 |
219 | rem --------------------------------------
220 | rem WAMPSERVER
221 | rem --------------------------------------
222 | rem Check WampServer install path exists
223 | rem --------------------------------------
224 |
225 | rem Check that the WampServer installation path exists.
226 | if not exist "%$config[wampServerInstallPath]%" (
227 | call :failure "Config File Error" "!$configPath!" "The WampServer installation path ^"!$config[wampServerInstallPath]!^" does not exist."
228 | ) else (
229 | call :logToFile "Found WampServer installation path at '!$config[wampServerInstallPath]!'"
230 | call :logToScreen "Found WampServer installation path."
231 | )
232 |
233 | rem Remove any trailing slash.
234 | call :removeTrailingSlash "%$config[wampServerInstallPath]%"
235 | set $config[wampServerInstallPath]=!$result!
236 |
237 |
238 | rem --------------------------
239 | rem APACHE
240 | rem --------------------------
241 | rem Check Apache path exists
242 | rem --------------------------
243 |
244 | rem Check that the WampServer Apache folder path exists.
245 | if not exist "%$config[wampServerInstallPath]%\%$subPathToApacheFolders%" (
246 | call :failure "SSL Script" "ssl_conf.bat" "Path to WampServer Apache folder ^"!$config[wampServerInstallPath]!\!$subPathToApacheFolders!^" does not exist." "Please file an issue on github."
247 | ) else (
248 | call :logToFile "Found WampServer Apache path at '%$config[wampServerInstallPath]%\%$subPathToApacheFolders%'"
249 | call :logToScreen "Found WampServer Apache path."
250 | )
251 |
252 |
253 | rem -------------------------------
254 | rem Get installed Apache versions
255 | rem -------------------------------
256 |
257 | rem Initialise the counter.
258 | set $totalApacheVersionsInstalled=0
259 |
260 | call :logToBoth "Found WampServer Apache installation(s):"
261 |
262 | rem Iterate through the WampServer Apache folder paths adding each version folder to the array.
263 | for /f "delims=" %%a in ('dir %$config[wampServerInstallPath]%\%$subPathToApacheFolders% /AD /B') do (
264 |
265 | rem ------------------
266 | rem Get version path
267 | rem ------------------
268 |
269 | if "%%a" neq "modules_sup" (
270 | set /A $totalApacheVersionsInstalled=$totalApacheVersionsInstalled+1
271 | rem Set the Apache version folder path to the array.
272 | set $installedApacheVersionsArray[!$totalApacheVersionsInstalled!]=%%a
273 | set $installedApacheVersionPathsArray[!$totalApacheVersionsInstalled!]=%$config[wampServerInstallPath]%\%$subPathToApacheFolders%\%%a
274 | call :logToBoth " '%%a'"
275 | )
276 | )
277 |
278 |
279 | rem ------------------------------
280 | rem OS
281 | rem ------------------------------
282 | rem Check OS 'hosts' file exists
283 | rem ------------------------------
284 |
285 | rem Check if the OS 'hosts' file exists.
286 | if not exist "%$pathToOSHostsFile%" (
287 | call :failure "SSL Script Error" "ssl_conf.bat" "Path to OS 'hosts' file ^"!$pathToOSHostsFile!^" does not exist" "Please file an issue on github."
288 | )
289 |
290 | call :logToFile "Found OS 'hosts' file at '%$pathToOSHostsFile%'"
291 | call :logToScreen "Found OS 'hosts' file."
292 |
293 |
294 | rem -------------------------------
295 | rem Get OS service name of Apache
296 | rem -------------------------------
297 |
298 | rem Get the Apache (OS) service name from the WampServer 'wampmanager.conf' file.
299 | call :getIniValue "%$config[wampServerInstallPath]%\wampmanager.conf" "service" "ServiceApache"
300 |
301 | rem Check if a result was return.
302 | if [!$result!] == [] (
303 | call :failure "SSL Script Error" "ssl_conf.bat" "Unable to find 'ServiceApache' key in ^"!$config[wampServerInstallPath]!\wampmanager.conf^"" "Please file an issue on github."
304 | )
305 |
306 | rem Strip the surrounding quotes from the value.
307 | set $apacheServiceName=!$result:~1,-1!
308 | call :logToFile "Found OS Apache service name '!$apacheServiceName!'"
309 | call :logToScreen "Found OS Apache service name."
310 |
311 |
312 | rem --------------------
313 | rem Restore (CLI Flag)
314 | rem --------------------
315 |
316 | rem Check if the restore flag is set to true.
317 | if /i "!$restoreFlag!" equ "true" (
318 |
319 | rem ------------------------------
320 | rem Loop through Apache versions
321 | rem ------------------------------
322 |
323 | call :logToBoth "Restoring Apache config file(s):"
324 |
325 | rem Iterate though the installed Apache version folders.
326 | for /l %%a in (1,1,%$totalApacheVersionsInstalled%) do (
327 |
328 | rem ----------------------------
329 | rem Restore Apache config file
330 | rem ----------------------------
331 |
332 | rem Check if the 'httpd-backup.conf' file exists.
333 | if exist "!$installedApacheVersionPathsArray[%%a]!\conf\httpd-backup.conf" (
334 |
335 | rem Restore the 'httpd.conf' file.
336 | type "!$installedApacheVersionPathsArray[%%a]!\conf\httpd-backup.conf" > "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
337 |
338 | rem Delete the 'httpd-backup.conf' file.
339 | call :deleteFileIfExists "!$installedApacheVersionPathsArray[%%a]!\conf\httpd-backup.conf"
340 |
341 | call :logToBoth " '!$installedApacheVersionsArray[%%a]!' restored."
342 | ) else (
343 | call :logToBoth " '!$installedApacheVersionsArray[%%a]!' backup not found."
344 | )
345 |
346 | rem --------------------------------
347 | rem Validate Apache config file(s)
348 | rem --------------------------------
349 |
350 | rem Get the validity of the Apache config file(s).
351 | call :validateApacheConfigFile "!$installedApacheVersionPathsArray[%%a]!"
352 |
353 | rem Check the result.
354 | if "!$result!" neq "Syntax OK" (
355 | call :failure "WampServer Apache Validation Error" "See below" "!$result!" "Please correct the error in the stated configuration file and restart WampServer."
356 | )
357 |
358 | call :logToBoth " '!$installedApacheVersionsArray[%%a]!' validated."
359 | )
360 |
361 |
362 | rem ----------------------
363 | rem Loop through domains
364 | rem ----------------------
365 |
366 | call :logToBoth "Deleting certificates from store:"
367 |
368 | rem Iterate through all config listed domains.
369 | for /l %%a in (1,1,%$totalConfigDomains%) do (
370 |
371 | rem -----------------------------------
372 | rem Delete cert(s) from Windows store
373 | rem -----------------------------------
374 |
375 | rem Delete certificate from 'trusted root certificate store'.
376 | rem View store by entering 'certmgr.msc' at the command line.
377 | certutil -delstore "root" "!$config[%%a][hostname]!" > nul
378 | call :logToBoth " '!$config[%%a][hostname]!'"
379 | )
380 |
381 |
382 | rem -------------------------
383 | rem Restore OS 'hosts' file
384 | rem -------------------------
385 |
386 | rem Set 'hosts' file updated flag.
387 | set $osHostsFileUpdated=false
388 |
389 | call :logToBoth "Attempting to restore OS 'hosts' file."
390 |
391 | rem Check if the OS 'hosts-backup' file exists.
392 | if exist "%$pathToOSHostsFile%-backup" (
393 |
394 | rem Restore the OS 'hosts' file.
395 | rem Unable to redirect error output without breaking updating of file...
396 | type "!$pathToOSHostsFile!-backup" > "!$pathToOSHostsFile!" 2>nul
397 |
398 | rem Check if the OS 'hosts' file matches the 'hosts-backup'file.
399 | fc "!$pathToOSHostsFile!-backup" "!$pathToOSHostsFile!" >nul && (
400 | set $osHostsFileUpdated=true
401 | call :deleteFileIfExists "!$pathToOSHostsFile!-backup" 2>nul
402 | call :logToBoth "Restored OS 'hosts' file."
403 | ) || (
404 | call :logToBoth "Unable to restore OS 'hosts' file."
405 | )
406 | ) else (
407 | set $osHostsFileUpdated=true
408 | call :logToBoth "OS 'hosts' backup file not found."
409 | )
410 |
411 | rem ----------------
412 | rem Restart Apache
413 | rem ----------------
414 |
415 | rem Restart Apache.
416 | call :logToBoth "Re-starting Apache."
417 | call :restartApache
418 | call :logToBoth "Re-started Apache."
419 |
420 |
421 | rem ----------------------------------
422 | rem Exit showing appropriate message
423 | rem ----------------------------------
424 | if /i "!$osHostsFileUpdated!" equ "false" (
425 | call :warning
426 | ) else (
427 | call :success
428 | )
429 | )
430 |
431 |
432 | rem ------------------------------
433 | rem APACHE
434 | rem ------------------------------
435 | rem Loop through Apache versions
436 | rem ------------------------------
437 |
438 | call :logToBoth "Validating Apache config file(s):"
439 |
440 | rem Iterate though the installed Apache version folders.
441 | for /l %%a in (1,1,%$totalApacheVersionsInstalled%) do (
442 |
443 | rem ------------------------------
444 | rem Validate Apache config files
445 | rem ------------------------------
446 |
447 | rem Get the validity of the Apache config file(s).
448 | call :validateApacheConfigFile "!$installedApacheVersionPathsArray[%%a]!"
449 |
450 | rem Check the result.
451 | if "!$result!" neq "Syntax OK" (
452 | call :failure "WampServer Apache Validation Error" "See below" "!$result!" "Please correct the error in the stated configuration file and restart WampServer."
453 | )
454 |
455 | call :logToBoth " '!$installedApacheVersionsArray[%%a]!'"
456 | )
457 |
458 |
459 | rem ------------------------------------
460 | rem Get latest OpenSSL executable path
461 | rem ------------------------------------
462 |
463 | rem Use the latest Apache version folder.
464 | set $pathToLatestOpenSslExe=!$installedApacheVersionPathsArray[%$totalApacheVersionsInstalled%]!\!$subPathToApacheOpenSslExe!
465 | call :logToBoth "Using 'openssl.exe' from '!$installedApacheVersionsArray[%$totalApacheVersionsInstalled%]!'"
466 |
467 |
468 | rem ---------------------------------
469 | rem Start Apache service if stopped
470 | rem ---------------------------------
471 |
472 | rem Get the status of the Apache service.
473 | call :getServiceStatus "!$apacheServiceName!"
474 |
475 | rem Start Apache service if it is not already running.
476 | if /i "!$result!" neq "Running" (
477 | call :logToBoth "Starting Apache service."
478 |
479 | rem Start Apache.
480 | net start !$apacheServiceName! > nul
481 |
482 | rem Get the status of the Apache service.
483 | call :getServiceStatus "!$apacheServiceName!"
484 |
485 | rem Check if the Apache service is running.
486 | if /i "!$result!" neq "Running" (
487 | call :failure "WampServer Apache Service Startup Error" "See below" "!$result!" "Please correct the error and restart WampServer."
488 | ) else (
489 | call :logToBoth "Apache service started."
490 | )
491 | ) else (
492 | call :logToBoth "Apache service already started."
493 | )
494 |
495 |
496 | rem ------------------------------------
497 | rem BACKUP
498 | rem ------------------------------------
499 | rem Backup OS 'hosts' file (once only)
500 | rem ------------------------------------
501 | if not exist "%$pathToOSHostsFile%-backup" (
502 | type "!$pathToOSHostsFile!" > "!$pathToOSHostsFile!-backup"
503 | call :logToBoth "OS 'hosts' file backed up."
504 | ) else (
505 | call :logToBoth "OS 'hosts' file already backed up."
506 | )
507 |
508 |
509 | rem ------------------------------
510 | rem Loop through Apache versions
511 | rem ------------------------------
512 |
513 | call :logToBoth "Backing up Apache 'httpd.conf' file(s):"
514 |
515 | rem Iterate though the installed Apache version folders.
516 | for /l %%a in (1,1,%$totalApacheVersionsInstalled%) do (
517 |
518 | rem ---------------------------------------------
519 | rem Backup Apache 'httpd.conf' file (once only)
520 | rem ---------------------------------------------
521 | if not exist "!$installedApacheVersionPathsArray[%%a]!\conf\httpd-backup.conf" (
522 | type "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf" > "!$installedApacheVersionPathsArray[%%a]!\conf\httpd-backup.conf"
523 | call :logToBoth " '!$installedApacheVersionsArray[%%a]!'"
524 | ) else (
525 | call :logToBoth " '!$installedApacheVersionsArray[%%a]!' already backed up."
526 | )
527 | )
528 |
529 |
530 | rem --------------------------------------------------------
531 | rem Create common 'certs', 'logs' And 'vhosts' directories
532 | rem --------------------------------------------------------
533 | if not exist "%$config[wampServerExtensionsPath]%\certs" (
534 | md "%$config[wampServerExtensionsPath]%\certs"
535 | call :logToFile "Created common 'certs' directory at '!$config[wampServerExtensionsPath]!\certs'"
536 | call :logToScreen "Created common 'certs' directory."
537 | ) else (
538 | call :logToFile "Common 'certs' directory already exists at '!$config[wampServerExtensionsPath]!\certs'"
539 | call :logToScreen "Common 'certs' directory already exists."
540 | )
541 |
542 | if not exist "%$config[wampServerExtensionsPath]%\vhosts\http" (
543 | md "%$config[wampServerExtensionsPath]%\vhosts\http"
544 | call :logToFile "Created common 'vhosts\http' directory at '!$config[wampServerExtensionsPath]!\vhosts\http'"
545 | call :logToScreen "Created common 'vhosts\http' directory."
546 | ) else (
547 | call :logToFile "Common 'vhosts\http' directory already exists at '!$config[wampServerExtensionsPath]!\vhosts\http'"
548 | call :logToScreen "Common 'vhosts\http' directory already exists."
549 | )
550 |
551 | if not exist "%$config[wampServerExtensionsPath]%\vhosts\https\conf" (
552 | md "%$config[wampServerExtensionsPath]%\vhosts\https\conf"
553 | call :logToFile "Created common 'vhosts\https' directory at '!$config[wampServerExtensionsPath]!\vhosts\https'"
554 | call :logToScreen "Created common 'vhosts\https' directory."
555 | ) else (
556 | call :logToFile "Common 'vhosts\https' directory already exists at '!$config[wampServerExtensionsPath]!\vhosts\https'"
557 | call :logToScreen "Common 'vhosts\https' directory already exists."
558 | )
559 |
560 |
561 | rem ------------------------------------------------
562 | rem (Re)Create common vhosts 'httpd-ssl.conf' file
563 | rem ------------------------------------------------
564 | if not exist "%$config[wampServerExtensionsPath]%\vhosts\https\conf\httpd-ssl.conf" (
565 | (call :httpdSslCommonConfigFile) >> "%$config[wampServerExtensionsPath]%\vhosts\https\conf\httpd-ssl.conf"
566 | call :logToBoth "Created common 'httpd-ssl.conf' file."
567 | ) else (
568 | call :deleteFileIfExists "%$config[wampServerExtensionsPath]%\vhosts\https\conf\httpd-ssl.conf"
569 | (call :httpdSslCommonConfigFile) >> "%$config[wampServerExtensionsPath]%\vhosts\https\conf\httpd-ssl.conf"
570 | call :logToBoth "Re-created common 'httpd-ssl.conf' file."
571 | )
572 |
573 |
574 | rem ----------------------
575 | rem Loop through domains
576 | rem ----------------------
577 |
578 | rem Iterate through all config listed domains.
579 | for /l %%a in (1,1,%$totalConfigDomains%) do (
580 |
581 | rem Set the variables for easier replacement in the config files.
582 | set $config[name]=!$config[%%a][name]!
583 | set $config[hostname]=!$config[%%a][hostname]!
584 | set $config[documentRoot]=!$config[%%a][documentRoot]!
585 | set $config[http2]=!$config[%%a][http2]!
586 |
587 | rem Show domain name.
588 | call :logToBoth "---------------------------------------------"
589 | call :logToBoth "!$config[name]! ^(!$config[hostname]!^)"
590 |
591 |
592 | rem ---------------------------
593 | rem Create domain directories
594 | rem ---------------------------
595 |
596 | rem Create the 'certs' directory.
597 | if not exist "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!" (
598 | md "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!"
599 | call :logToBoth " 'certs' directory created."
600 | ) else (
601 | call :logToBoth " 'certs' directory already exists."
602 | )
603 |
604 | rem Create the 'logs' directory.
605 | if not exist "!$config[wampServerExtensionsPath]!\logs\!$config[hostname]!" (
606 | md "!$config[wampServerExtensionsPath]!\logs\!$config[hostname]!"
607 | call :logToBoth " 'logs' directory created."
608 | ) else (
609 | call :logToBoth " 'logs' directory already exists."
610 | )
611 |
612 |
613 | rem -------------------------------
614 | rem (Re)Create 'openssl.cnf' file
615 | rem -------------------------------
616 | if not exist "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\openssl.cnf" (
617 | (call :openSslCnfFile) >> "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\openssl.cnf"
618 | call :logToBoth " Created 'openssl.conf' file."
619 | ) else (
620 | call :deleteFileIfExists "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\openssl.cnf"
621 | (call :openSslCnfFile) >> "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\openssl.cnf"
622 | call :logToBoth " Re-created 'openssl.cnf' file."
623 | )
624 |
625 |
626 | rem ----------------------------
627 | rem (Re)Create HTTP vhost file
628 | rem ----------------------------
629 | if not exist "!$config[wampServerExtensionsPath]!\vhosts\http\!$config[hostname]!.conf" (
630 | (call :apache24HttpVhostConfigFile) >> "%$config[wampServerExtensionsPath]%\vhosts\http\!$config[hostname]!.conf"
631 | call :logToBoth " Created Virtual Host http file."
632 | ) else (
633 | call :deleteFileIfExists "!$config[wampServerExtensionsPath]!\vhosts\http\!$config[hostname]!.conf"
634 | (call :apache24HttpVhostConfigFile) >> "%$config[wampServerExtensionsPath]%\vhosts\http\!$config[hostname]!.conf"
635 | call :logToBoth " Re-created Virtual Host http file."
636 | )
637 |
638 |
639 | rem -----------------------------
640 | rem (Re)Create HTTPS vhost file
641 | rem -----------------------------
642 | if not exist "!$config[wampServerExtensionsPath]!\vhosts\https\!$config[hostname]!.conf" (
643 | if /i "!$config[http2]!" equ "false" (
644 | (call :apache24Https11VhostConfigFile) >> "!$config[wampServerExtensionsPath]!\vhosts\https\!$config[hostname]!.conf"
645 | ) else (
646 | (call :apache24Https2VhostConfigFile) >> "!$config[wampServerExtensionsPath]!\vhosts\https\!$config[hostname]!.conf"
647 | )
648 | call :logToBoth " Created Virtual Host https file."
649 | ) else (
650 | call :deleteFileIfExists "!$config[wampServerExtensionsPath]!\vhosts\https\!$config[hostname]!.conf"
651 | if /i "!$config[http2]!" equ "false" (
652 | (call :apache24Https11VhostConfigFile) >> "!$config[wampServerExtensionsPath]!\vhosts\https\!$config[hostname]!.conf"
653 | ) else (
654 | (call :apache24Https2VhostConfigFile) >> "!$config[wampServerExtensionsPath]!\vhosts\https\!$config[hostname]!.conf"
655 | )
656 | call :logToBoth " Re-created Virtual Host https file."
657 | )
658 |
659 |
660 | rem ------------------------------------
661 | rem Delete old cert from Windows store
662 | rem ------------------------------------
663 |
664 | rem Delete certificate from 'trusted root certificate store'.
665 | rem View store by entering 'certmgr.msc' at the command line.
666 | certutil -delstore "root" "!$config[hostname]!" > nul
667 | call :logToBoth " Deleted old certificate from store."
668 |
669 |
670 | rem -----------------------
671 | rem Create SSL key & cert
672 | rem -----------------------
673 |
674 | rem Create private (and public) RSA key.
675 | cmd /C !$pathToLatestOpenSslExe! "genrsa" "-out" "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\private.pem" 2> nul
676 | call :logToBoth " Generated certificate keys."
677 |
678 | rem Remove private key passphrase.
679 | cmd /C !$pathToLatestOpenSslExe! "rsa" "-in" "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\private.pem" "-out" "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\private.key" 2> nul
680 | call :logToBoth " Removed certificate passphrase."
681 |
682 | rem Generate self signed certificate.
683 | cmd /C !$pathToLatestOpenSslExe! "req" "-x509" "-days" "!$config[sslDays]!" "-key" "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\private.key" "-out" "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\server.crt" "-config" "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\openssl.cnf"
684 | call :logToBoth " Generated Certificate."
685 |
686 | rem Delete the redundant RSA key file.
687 | call :deleteFileIfExists "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\private.pem"
688 | call :logToBoth " Deleted 'private.pem' file."
689 |
690 |
691 | rem -------------------------------
692 | rem Add new cert to Windows store
693 | rem -------------------------------
694 |
695 | rem Add certificate to 'trusted root certificate store'.
696 | rem View store by entering 'certmgr.msc' at the command line.
697 | certutil -f -addstore "root" "!$config[wampServerExtensionsPath]!\certs\!$config[hostname]!\server.crt" > nul
698 | call :logToBoth " Added new certificate to store."
699 |
700 |
701 | rem -------------------------------
702 | rem Add domain to OS 'hosts' file
703 | rem -------------------------------
704 |
705 | rem Set 'hosts' file updated flag.
706 | set $osHostsFileUpdated=false
707 |
708 | rem Check if the hostname has already been added to the 'hosts' file.
709 | call :findInFile "]# Hostname: !$config[hostname]!" "!$pathToOSHostsFile!"
710 |
711 | rem Check the result.
712 | if /i "!$result!" equ "false" (
713 | rem Try adding the hostname.
714 | call :logToBoth " Attempting to add hostname to OS 'hosts' file."
715 | rem Unable to redirect error output without breaking updating of file...
716 | (call :includeOsHostsFile) >> "!$pathToOSHostsFile!" 2>nul
717 |
718 | rem Check if the hostname has been added.
719 | call :findInFile "]# Hostname: !$config[hostname]!" "!$pathToOSHostsFile!"
720 |
721 | rem Check the result.
722 | if /i "!$result!" equ "true" (
723 | set $osHostsFileUpdated=true
724 | call :logToBoth " Hostname added to OS 'hosts' file."
725 | ) else (
726 | call :logToBoth " Unable to added hostname to OS 'hosts' file."
727 | )
728 | ) else (
729 | rem Hostname already added to the 'hosts' file.
730 | set $osHostsFileUpdated=true
731 | call :logToBoth " Hostname already added to OS 'hosts' file."
732 | )
733 | )
734 |
735 | call :logToBoth "---------------------------------------------"
736 |
737 |
738 | rem ------------------------------
739 | rem Loop through Apache versions
740 | rem ------------------------------
741 |
742 | call :logToBoth "Updating Apache primary config file(s):"
743 |
744 | rem Iterate though the installed Apache version folders.
745 | for /l %%a in (1,1,%$totalApacheVersionsInstalled%) do (
746 |
747 | rem Show the header info.
748 | call :logToBoth " '!$installedApacheVersionsArray[%%a]!\conf\httpd.conf'"
749 |
750 |
751 | rem --------------------------------------------
752 | rem Uncomment 'socache_shmcb_module' module
753 | rem
754 | rem Low level shared memory based object cache
755 | rem for caching information such as SSL
756 | rem sessions and authentication credentials.
757 | rem --------------------------------------------
758 |
759 | rem Check if the module is commented out / disabled.
760 | call :findInFile "]#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so" "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
761 | if /i "!$result!" equ "true" (
762 | rem Uncomment / enable the module.
763 | call :findAndReplaceInFile "]#LoadModule socache_shmcb_module modules/mod_socache_shmcb.so" "]LoadModule socache_shmcb_module modules/mod_socache_shmcb.so" "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
764 | call :logToBoth " 'socache_shmcb_module' uncommented."
765 | ) else (
766 | rem Module already uncommented / enabled.
767 | call :logToBoth " 'socache_shmcb_module' already uncommented."
768 | )
769 |
770 |
771 | rem -------------------------------
772 | rem Uncomment 'ssl_module' module
773 | rem
774 | rem This module used the socache
775 | rem interface to provide a
776 | rem session cache and stapling
777 | rem cache.
778 | rem -------------------------------
779 |
780 | rem Check if the module is commented out / disabled.
781 | call :findInFile "]#LoadModule ssl_module modules/mod_ssl.so" "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
782 | if /i "!$result!" equ "true" (
783 | rem Uncomment / enable the module.
784 | call :findAndReplaceInFile "]#LoadModule ssl_module modules/mod_ssl.so" "]LoadModule ssl_module modules/mod_ssl.so" "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
785 | call :logToBoth " 'ssl_module' uncommented."
786 | ) else (
787 | rem Module already uncommented / enabled.
788 | call :logToBoth " 'ssl_module' already uncommented."
789 | )
790 |
791 |
792 | rem -----------------------------------------
793 | rem Uncomment 'http2_module' module
794 | rem
795 | rem This module enables HTTP/2 support.
796 | rem
797 | rem HTTP/2 functionality set per development
798 | rem domain.
799 | rem
800 | rem OpenSSL version must be greater than or
801 | rem equal to 1.0.2 for HTTP/2 compatibility.
802 | rem
803 | rem OpenSSL cipher suite must be greater
804 | rem than or equal to TLS 1.3 for HTTP/2
805 | rem compatibility.
806 | rem -----------------------------------------
807 |
808 | rem Check if the module is commented out / disabled.
809 | call :findInFile "]#LoadModule http2_module modules/mod_http2.so" "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
810 | if /i "!$result!" equ "true" (
811 | rem Uncomment / enable the module.
812 | call :findAndReplaceInFile "]#LoadModule http2_module modules/mod_http2.so" "]LoadModule http2_module modules/mod_http2.so" "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
813 | call :logToBoth " 'http2_module' uncommented."
814 | ) else (
815 | rem Module already uncommented / enabled.
816 | call :logToBoth " 'http2_module' already uncommented."
817 | )
818 |
819 |
820 | rem ----------------------------------------
821 | rem Add vhosts HTTPS 'httpd-ssl.conf' link
822 | rem ----------------------------------------
823 |
824 | rem Check if the link has been added.
825 | call :findInFile "]# SSL Config - Additional" "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
826 | if /i "!$result!" equ "false" (
827 | rem Add the link.
828 | (call :includeSslInConfigFile) >> "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
829 | call :logToBoth " Added SSL Config link."
830 | ) else (
831 | rem Link already added.
832 | call :logToBoth " SSL Config link already added."
833 | )
834 |
835 |
836 | rem -------------------------------
837 | rem Add vhosts HTTP '*.conf' link
838 | rem -------------------------------
839 |
840 | rem Check if the link has been added.
841 | call :findInFile "]# HTTP Vhost(s) - Additional" "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
842 | if /i "!$result!" equ "false" (
843 | rem Add the link.
844 | (call :includeHttpVhostInConfigFile) >> "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
845 | call :logToBoth " Added HTTP vhosts link."
846 | ) else (
847 | rem Link already added.
848 | call :logToBoth " HTTP vhosts link already added."
849 | )
850 |
851 |
852 | rem --------------------------------
853 | rem Add vhosts HTTPS '*.conf' link
854 | rem --------------------------------
855 |
856 | rem Check if the link has been added.
857 | call :findInFile "]# HTTPS Vhost(s) - Additional" "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
858 | if /i "!$result!" equ "false" (
859 | rem Add the link.
860 | (call :includeHttpsVhostInConfigFile) >> "!$installedApacheVersionPathsArray[%%a]!\conf\httpd.conf"
861 | call :logToBoth " Added HTTPS vhosts link."
862 | ) else (
863 | rem Link already added.
864 | call :logToBoth " HTTPS vhosts link already added."
865 | )
866 |
867 |
868 | rem -----------------------
869 | rem Validate config files
870 | rem -----------------------
871 |
872 | rem Get the validity of the Apache config files.
873 | call :validateApacheConfigFile "!$installedApacheVersionPathsArray[%%a]!"
874 |
875 | rem Check the result.
876 | if "!$result!" neq "Syntax OK" (
877 | call :failure "WampServer Apache Validation Error" "See below" "!$result!" "Please correct the error in the stated configuration file and restart WampServer."
878 | )
879 |
880 | call :logToBoth " Validated config file(s)."
881 | )
882 |
883 | call :logToBoth "---------------------------------------------"
884 |
885 |
886 | rem -----------
887 | rem Flush DNS
888 | rem -----------
889 | call :logToBoth "Flushing DNS."
890 | ipconfig /flushdns > nul
891 | call :logToBoth "Flushed DNS."
892 |
893 |
894 | rem ---------------------
895 | rem Restart WampServer
896 | rem ---------------------
897 |
898 | rem Restart Apache.
899 | call :logToBoth "Re-starting Apache."
900 | call :restartApache
901 | call :logToBoth "Re-started Apache."
902 |
903 |
904 | rem ----------------------------------
905 | rem Exit showing appropriate message
906 | rem ----------------------------------
907 | if /i "!$osHostsFileUpdated!" equ "false" (
908 | call :warning
909 | ) else (
910 | call :success
911 | )
912 |
913 |
914 | rem ====================================================================================================================
915 | rem Functions
916 | rem ====================================================================================================================
917 |
918 | rem ---------------
919 | rem Log to screen
920 | rem ---------------
921 | :logToScreen $message
922 |
923 | rem Set the variable.
924 | set $message=%~1
925 |
926 | rem Display the message.
927 | echo %time% : !$message!
928 |
929 | exit /B
930 |
931 |
932 | rem -------------
933 | rem Log to file
934 | rem -------------
935 | :logToFile $message
936 |
937 | rem Set the variable.
938 | set $message=%~1
939 |
940 | rem Log the message.
941 | echo %time% : !$message! >> "!$logFilePath!"
942 |
943 | exit /B
944 |
945 |
946 | rem ----------------------
947 | rem Log to screen & file
948 | rem ----------------------
949 | :logToBoth $message
950 |
951 | call :logToScreen %1
952 | call :logToFile %1
953 |
954 | exit /B
955 |
956 |
957 | rem ----------------
958 | rem Restart Apache
959 | rem ----------------
960 | :restartApache
961 |
962 | rem Stop Apache.
963 | net stop %$apacheServiceName% > nul
964 |
965 | rem Start Apache.
966 | net start %$apacheServiceName% > nul
967 |
968 | exit /B
969 |
970 |
971 | rem -----------------------------
972 | rem Validate Apache config file
973 | rem -----------------------------
974 | :validateApacheConfigFile $file
975 |
976 | rem Set the variable scope.
977 | setlocal
978 |
979 | rem Set the variables.
980 | set $file=%~1
981 | set $output=
982 |
983 | rem As "all" Apache output goes to STDERR, we have redirect it back to STDOUT so it can be processed.
984 | for /f "tokens=* delims=" %%a in ('%$file%\%$subPathToApacheHttpdExe% -t 2^>^&1') do (
985 | set $output=%%a
986 | goto :exitValidateApacheConfigFilesFunction
987 | )
988 |
989 | :exitValidateApacheConfigFilesFunction
990 |
991 | endlocal & set $result=%$output%
992 |
993 | exit /B
994 |
995 |
996 | rem --------------------
997 | rem Get service status
998 | rem --------------------
999 | :getServiceStatus $name
1000 |
1001 | rem Set the variable scope.
1002 | setlocal
1003 |
1004 | rem Set the variables.
1005 | set $name=%~1
1006 | set $status=Unknown
1007 |
1008 | rem Set the service status.
1009 | for /F "tokens=3 delims=: " %%a in ('sc query "%$name%" ^| find "STATE"') do (
1010 |
1011 | if /i "%%a" equ "RUNNING" (
1012 | set $status=Running
1013 | )
1014 |
1015 | if /i "%%a" equ "STOPPED" (
1016 | set $status=Stopped
1017 | )
1018 | )
1019 |
1020 | endlocal & set $result=%$status%
1021 |
1022 | exit /B
1023 |
1024 |
1025 | rem -----------------------
1026 | rem Remove trailing slash
1027 | rem -----------------------
1028 | :removeTrailingSlash $string
1029 |
1030 | rem Set the variable scope.
1031 | setlocal
1032 |
1033 | rem Set the variable.
1034 | set $string=%~1
1035 |
1036 | rem Remove the backslash if one exists.
1037 | if "!$string:~-1%!" equ "\" (
1038 | set "$string=!$string:~0,-1!"
1039 | )
1040 |
1041 | rem Remove the forward slash if one exists.
1042 | if "!$string:~-1%!" equ "/" (
1043 | set "$string=!$string:~0,-1!"
1044 | )
1045 |
1046 | endlocal & set $result=%$string%
1047 |
1048 | exit /B
1049 |
1050 |
1051 | rem --------------------------
1052 | rem Delete file if it exists
1053 | rem --------------------------
1054 | :deleteFileIfExists $file
1055 |
1056 | rem Set the variable.
1057 | set $file=%~1
1058 |
1059 | if exist "%$file%" (
1060 | del /Q "%$file%"
1061 | )
1062 |
1063 | exit /B
1064 |
1065 |
1066 | rem -------------------------------------
1067 | rem Find and replace a string in a file
1068 | rem
1069 | rem To save on double parsing a file,
1070 | rem just parse, replace (if found) and
1071 | rem re-write even is no match is found.
1072 | rem -------------------------------------
1073 | :findAndReplaceInFile $find $replace $file
1074 |
1075 | rem Set the variable(s).
1076 | set $find=%~1
1077 | set $replace=%~2
1078 | set $file=%~3
1079 |
1080 | rem Delete the temporary file if one exists.
1081 | if exist "!$pathToUsersTempFile!" (
1082 | del /Q "!$pathToUsersTempFile!"
1083 | )
1084 |
1085 | rem Parse the $file one line at a time.
1086 | for /f "tokens=1,* delims=0123456789" %%a in ('find /n /v "" ^< "!$file!"') do (
1087 |
1088 | rem Set the variable(s).
1089 | set "$line=%%b"
1090 |
1091 | rem Check if the line matches.
1092 | if !$line!==!$find! (
1093 | rem Replace the line.
1094 | set "$line=!$replace!"
1095 | )
1096 |
1097 | rem Expand the line removing any surrounding quotes then write the line to the temporary file.
1098 | echo(!$line:~1!) >> "!$pathToUsersTempFile!"
1099 | )
1100 |
1101 | rem Overwrite the $file with the temporary file.
1102 | copy "!$pathToUsersTempFile!" "!$file!" > nul
1103 |
1104 | exit /B
1105 |
1106 |
1107 | rem -----------------------------
1108 | rem Check if it is an .ini file
1109 | rem -----------------------------
1110 | :isIniFile $file
1111 |
1112 | rem Set the variable scope.
1113 | setlocal
1114 |
1115 | rem Set the variables.
1116 | set $fileExtension=%~x1
1117 | set $boolean=false
1118 |
1119 | rem Check if the file extension is .ini
1120 | if /i "!$fileExtension!" equ ".ini" (
1121 | set $boolean=true
1122 | )
1123 |
1124 | endlocal & set $result=%$boolean%
1125 |
1126 | exit /B
1127 |
1128 |
1129 | rem -------------------------
1130 | rem Find a string in a file
1131 | rem -------------------------
1132 | :findInFile $find $file
1133 |
1134 | rem Set the variable scope.
1135 | setlocal
1136 |
1137 | rem Set the variable(s).
1138 | set $find=%~1
1139 | set $file=%~2
1140 | set $boolean=false
1141 |
1142 | rem Parse the file one line at a time.
1143 | for /f "tokens=1,* delims=0123456789" %%a in ('find /n /v "" ^< "!$file!"') do (
1144 |
1145 | rem Set the variable(s).
1146 | set "$line=%%b"
1147 |
1148 | rem Check if the line matches.
1149 | if /i "!$line!" equ "!$find!" (
1150 | set $boolean=true
1151 | )
1152 | )
1153 |
1154 | endlocal & set $result=%$boolean%
1155 |
1156 | exit /B
1157 |
1158 |
1159 | rem -------------------------------------
1160 | rem Get the .ini file section key value
1161 | rem -------------------------------------
1162 | :getIniValue $iniFile $section $key
1163 |
1164 | rem Set the variable scope.
1165 | setlocal
1166 |
1167 | rem Set the arguments.
1168 | set $iniFile=%~1
1169 | set $section=[%~2]
1170 | set $key=%~3
1171 |
1172 | rem Parse the config.ini file.
1173 | set $inSection=false
1174 | set $sectionLine=false
1175 | set $value=
1176 |
1177 | for /F "usebackq delims=" %%a in ("!$iniFile!") do (
1178 |
1179 | rem Set the line.
1180 | set $line=%%a
1181 |
1182 | rem Check for a matching section.
1183 | if "!$line:~0,1!" equ "[" (
1184 | if "!$line:~-1!" equ "]" (
1185 | set $sectionLine=true
1186 |
1187 | if "!$line!" equ "!$section!" (
1188 | set $inSection=true
1189 | ) else (
1190 | set $inSection=false
1191 | )
1192 | )
1193 | ) else (
1194 | set $sectionLine=false
1195 | )
1196 |
1197 | rem Check that we are within the matching section and at a key / value pair line.
1198 | if "!$inSection!" equ "true" (
1199 | if "!$sectionLine!" equ "false" (
1200 | for /F "tokens=1,2 delims==" %%b in ("!$line!") do (
1201 | rem Set the section key and remove any peripheral spaces.
1202 | set $sectionKey=%%b
1203 | set $sectionKey=!$sectionKey: =!
1204 |
1205 | rem Set the section value and remove any peripheral spaces.
1206 | set $sectionValue=%%c
1207 | set $sectionValue=!$sectionValue: =!
1208 |
1209 | rem Check for a matching keys.
1210 | if "!$sectionKey!" equ "!$key!" (
1211 | set $value=!$sectionValue!
1212 | )
1213 | )
1214 | )
1215 | )
1216 | )
1217 |
1218 | endlocal & set $result=%$value%
1219 |
1220 | exit /B
1221 |
1222 |
1223 | rem ====================================================================================================================
1224 | rem File Templates
1225 | rem ====================================================================================================================
1226 |
1227 | rem -----------------------------------------------------------
1228 | rem The vhosts 'httpd-ssl.conf' configuration (template) file
1229 | rem -----------------------------------------------------------
1230 | :httpdSslCommonConfigFile
1231 |
1232 | echo Listen 443
1233 | echo:
1234 | echo # SSL Cipher Suite:
1235 | echo SSLCipherSuite HIGH:MEDIUM:^^!MD5:^^!RC4:^^!3DES
1236 | echo SSLProxyCipherSuite HIGH:MEDIUM:^^!MD5:^^!RC4:^^!3DES
1237 | echo:
1238 | echo # Enforce the server's cipher order.
1239 | echo SSLHonorCipherOrder on
1240 | echo:
1241 | echo # SSL Protocol support:
1242 | echo SSLProtocol all -SSLv3
1243 | echo SSLProxyProtocol all -SSLv3
1244 | echo:
1245 | echo # Pass Phrase Dialog:
1246 | echo SSLPassPhraseDialog builtin
1247 | echo:
1248 | echo # Inter-Process Session Cache:
1249 | echo SSLSessionCache "shmcb:c:/Apache24/logs/ssl_scache(512000)"
1250 | echo SSLSessionCacheTimeout 300
1251 |
1252 | exit /B
1253 |
1254 |
1255 | rem ---------------------------------------------------------
1256 | rem The OpenSSL 'openssl.cnf' configuration (template) file
1257 | rem ---------------------------------------------------------
1258 | :openSslCnfFile
1259 |
1260 | echo #
1261 | echo # OpenSSL config file for !$config[name]!
1262 | echo #
1263 | echo:
1264 | echo [req]
1265 | echo default_bits = 2048
1266 | echo default_md = sha256
1267 | echo distinguished_name = dn
1268 | echo x509_extensions = san
1269 | echo req_extensions = san
1270 | echo extensions = san
1271 | echo prompt = no
1272 | echo:
1273 | echo [dn]
1274 | echo C = !$config[sslCountry]!
1275 | echo ST = !$config[sslState]!
1276 | echo L = !$config[sslCity]!
1277 | echo O = !$config[sslOrganization]!
1278 | echo OU = !$config[sslOrganizationUnit]!
1279 | echo CN = !$config[hostname]!
1280 | echo emailAddress = !$config[sslEmail]!!$config[hostname]!
1281 | echo:
1282 | echo [san]
1283 | echo subjectAltName = DNS:!$config[hostname]!
1284 |
1285 | exit /B
1286 |
1287 |
1288 | rem --------------------------------------------------------------
1289 | rem The vhosts 'httpd-vhosts.conf' configuration (template) file
1290 | rem --------------------------------------------------------------
1291 | :apache24HttpVhostConfigFile
1292 |
1293 | echo # Virtual Host - http://!$config[hostname]!
1294 | echo #
1295 | echo ^
1296 | echo:
1297 | echo ServerName !$config[hostname]!
1298 | echo ServerAlias !$config[hostname]!
1299 | echo ServerAdmin admin@!$config[hostname]!
1300 | echo DocumentRoot "!$config[documentRoot]!"
1301 | echo:
1302 | echo ^
1303 | echo Options +Indexes +Includes +FollowSymLinks +MultiViews
1304 | echo AllowOverride All
1305 | echo Require local
1306 | echo Require ip !$ipNetworkPart!
1307 | echo ^
1308 | echo:
1309 | echo ^
1310 |
1311 | exit /B
1312 |
1313 |
1314 | rem ---------------------------------------------------------------------------
1315 | rem The vhosts 'httpd-ssl.conf' configuration (template) file (with HTTP/1.1)
1316 | rem ---------------------------------------------------------------------------
1317 | :apache24Https11VhostConfigFile
1318 |
1319 | echo # Virtual Host - https://!$config[hostname]!
1320 | echo #
1321 | echo ^
1322 | echo:
1323 | echo ServerName !$config[hostname]!
1324 | echo ServerAlias !$config[hostname]!
1325 | echo ServerAdmin admin@%!$config[hostname]!
1326 | echo DocumentRoot "!$config[documentRoot]!"
1327 | echo:
1328 | echo ^
1329 | echo SSLOptions +StdEnvVars
1330 | echo Options +Indexes +Includes +FollowSymLinks +MultiViews
1331 | echo AllowOverride All
1332 | echo Require local
1333 | echo Require ip !$ipNetworkPart!
1334 | echo ^
1335 | echo:
1336 | echo SSLEngine on
1337 | echo:
1338 | echo SSLCertificateFile "!$config[wampServerExtensionsPath]!/certs/!$config[hostname]!/server.crt"
1339 | echo SSLCertificateKeyFile "!$config[wampServerExtensionsPath]!/certs/!$config[hostname]!/private.key"
1340 | echo:
1341 | echo LogFormat "%%L [%%{%%a, %%d-%%b-%%g %%T}t %%{%%z}t] %%H %%m \"%%U%%q\" (%%b bytes) %%>s" access
1342 | echo CustomLog "!$config[wampServerExtensionsPath]!/logs/!$config[hostname]!/access.log" access
1343 | echo:
1344 | echo ErrorLogFormat "%%L [%%t] [%%-m:%%l] [pid %%P:tid %%T] %%E: %%a %%M"
1345 | echo ErrorLog "!$config[wampServerExtensionsPath]!/logs/!$config[hostname]!/error.log"
1346 | echo:
1347 | echo LogFormat "%%L [%%{%%a, %%d-%%b-%%g %%T}t %%{%%z}t] %%H %%{SSL_PROTOCOL}x %%{SSL_CIPHER}x %%m \"%%U%%q\" (%%b bytes) %%>s" ssl
1348 | echo CustomLog "!$config[wampServerExtensionsPath]!/logs/!$config[hostname]!/ssl_request.log" ssl
1349 | echo:
1350 | echo ^
1351 |
1352 | exit /B
1353 |
1354 |
1355 | rem -------------------------------------------------------------------------
1356 | rem The vhosts 'httpd-ssl.conf' configuration (template) file (with HTTP/2)
1357 | rem -------------------------------------------------------------------------
1358 | :apache24Https2VhostConfigFile
1359 |
1360 | echo # Virtual Host - https://!$config[hostname]!
1361 | echo #
1362 | echo ^
1363 | echo:
1364 | echo ServerName !$config[hostname]!
1365 | echo ServerAlias !$config[hostname]!
1366 | echo ServerAdmin admin@%!$config[hostname]!
1367 | echo DocumentRoot "!$config[documentRoot]!"
1368 | echo:
1369 | echo ^
1370 | echo SSLOptions +StdEnvVars
1371 | echo Options +Indexes +Includes +FollowSymLinks +MultiViews
1372 | echo AllowOverride All
1373 | echo Require local
1374 | echo Require ip !$ipNetworkPart!
1375 | echo ^
1376 | echo:
1377 | echo SSLEngine on
1378 | echo:
1379 | echo SSLCertificateFile "!$config[wampServerExtensionsPath]!/certs/!$config[hostname]!/server.crt"
1380 | echo SSLCertificateKeyFile "!$config[wampServerExtensionsPath]!/certs/!$config[hostname]!/private.key"
1381 | echo:
1382 | echo LogFormat "%%L [%%{%%a, %%d-%%b-%%g %%T}t %%{%%z}t] %%H %%m \"%%U%%q\" (%%b bytes) %%>s" access
1383 | echo CustomLog "!$config[wampServerExtensionsPath]!/logs/!$config[hostname]!/access.log" access
1384 | echo:
1385 | echo ErrorLogFormat "%%L [%%t] [%%-m:%%l] [pid %%P:tid %%T] %%E: %%a %%M"
1386 | echo ErrorLog "!$config[wampServerExtensionsPath]!/logs/!$config[hostname]!/error.log"
1387 | echo:
1388 | echo LogFormat "%%L [%%{%%a, %%d-%%b-%%g %%T}t %%{%%z}t] %%H %%{SSL_PROTOCOL}x %%{SSL_CIPHER}x %%m \"%%U%%q\" (%%b bytes) %%>s" ssl
1389 | echo CustomLog "!$config[wampServerExtensionsPath]!/logs/!$config[hostname]!/ssl_request.log" ssl
1390 | echo:
1391 | echo SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
1392 | echo Protocols h2 http/1.1
1393 | echo:
1394 | echo ^
1395 |
1396 | exit /B
1397 |
1398 |
1399 | rem ------------------------------------------
1400 | rem Include SSL in Apache configuration file
1401 | rem ------------------------------------------
1402 | :includeSslInConfigFile
1403 |
1404 | echo:
1405 | echo # SSL Config - Additional
1406 | echo Include "!$config[wampServerExtensionsPath]!/vhosts/https/conf/httpd-ssl.conf"
1407 |
1408 | exit /B
1409 |
1410 |
1411 | rem ----------------------------------------------------
1412 | rem Include http vhost(s) in Apache configuration file
1413 | rem ----------------------------------------------------
1414 | :includeHttpVhostInConfigFile
1415 |
1416 | echo:
1417 | echo # HTTP Vhost(s) - Additional
1418 | echo Include "!$config[wampServerExtensionsPath]!/vhosts/http/*.conf"
1419 |
1420 | exit /B
1421 |
1422 |
1423 | rem -----------------------------------------------------
1424 | rem Include https vhost(s) in Apache configuration file
1425 | rem -----------------------------------------------------
1426 | :includeHttpsVhostInConfigFile
1427 |
1428 | echo:
1429 | echo # HTTPS Vhost(s) - Additional
1430 | echo Include "!$config[wampServerExtensionsPath]!/vhosts/https/*.conf"
1431 |
1432 | exit /B
1433 |
1434 |
1435 | rem -------------------------------------
1436 | rem Include hostname in OS 'hosts' file
1437 | rem -------------------------------------
1438 | :includeOsHostsFile
1439 |
1440 | echo:
1441 | echo # Name: !$config[name]!
1442 | echo # Hostname: !$config[hostname]!
1443 | echo # Doc Root: !$config[documentRoot]!
1444 | echo # IP Address: !$ipAddress!
1445 | echo # Notes: To access this hostname from another LAN computer, add
1446 | echo # "!$ipAddress! !$config[hostname]!" to their 'hosts' file.
1447 | echo # Added By: WampServer SSL Auto Config script.
1448 | echo 127.0.0.1 !$config[hostname]!
1449 | echo ::1 !$config[hostname]!
1450 |
1451 | exit /B
1452 |
1453 |
1454 | rem ====================================================================================================================
1455 | rem Success Message
1456 | rem ====================================================================================================================
1457 | :success
1458 | echo:
1459 | echo -----------------------------------------------------------
1460 | echo:
1461 | echo SUCCESS
1462 | echo:
1463 | echo -----------------------------------------------------------
1464 | echo:
1465 | echo Please refresh / restart any open web browsers.
1466 | echo:
1467 | echo Goodbye.
1468 | echo:
1469 | echo -----------------------------------------------------------
1470 | echo:
1471 | echo Press any key to exit.
1472 | pause >nul
1473 |
1474 | exit 0
1475 |
1476 |
1477 | rem ====================================================================================================================
1478 | rem Warning Message
1479 | rem ====================================================================================================================
1480 | :warning
1481 | echo:
1482 | echo -----------------------------------------------------------
1483 | echo:
1484 | echo WARNING
1485 | echo:
1486 | echo -----------------------------------------------------------
1487 | echo:
1488 | echo Unable To Modify The OS 'hosts' File
1489 | echo:
1490 | echo This step may have failed because of the following reasons:
1491 | echo 1. You are not a member of the Administrators group.
1492 | echo 2. Your virus protection software is preventing this script
1493 | echo from updating the 'hosts' file.
1494 | echo:
1495 | echo To fix this problem you can either:
1496 | echo 1. Add yourself to the Administrators group and run this
1497 | echo script again.
1498 | echo 2. Temporarily disable your virus protection software and
1499 | echo run this script again (or add the name of this script
1500 | echo to your virus protection software trusted applications
1501 | echo list^).
1502 | echo:
1503 | echo If you are already a member of the Administrators group
1504 | echo then the most probable cause is your virus protection
1505 | echo software.
1506 | echo:
1507 | echo -----------------------------------------------------------
1508 | echo:
1509 | echo Press any key to exit.
1510 | pause >nul
1511 |
1512 | exit 1
1513 |
1514 |
1515 | rem ====================================================================================================================
1516 | rem Failure Message
1517 | rem ====================================================================================================================
1518 | :failure $title $file $error $message
1519 |
1520 | rem Set the variable.
1521 | set $title=%~1
1522 | set $file=%~2
1523 | set $error=%~3
1524 | set $message=%~4
1525 |
1526 | echo:
1527 | echo -----------------------------------------------------------
1528 | echo:
1529 | echo FAILURE
1530 | echo:
1531 | echo -----------------------------------------------------------
1532 | echo:
1533 | echo %$title%
1534 | echo:
1535 | echo: File: %$file%
1536 | echo Error: %$error%
1537 | echo:
1538 | if /i "!$message!" neq "" (
1539 | echo %$message%
1540 | echo:
1541 | )
1542 | echo -----------------------------------------------------------
1543 | echo:
1544 | echo Press any key to exit.
1545 | pause >nul
1546 |
1547 | exit 1
--------------------------------------------------------------------------------
/testing/Test 1 - CLI - No Arguments.bat:
--------------------------------------------------------------------------------
1 | rem Test failure when no CLI arguments given.
2 |
3 | call "../ssl_config.bat"
--------------------------------------------------------------------------------
/testing/Test 10 - Script - OS Hosts File Path Corrupt.txt:
--------------------------------------------------------------------------------
1 | // Test failure when path to OS 'hosts' file is corrupt.
2 |
3 | File: ssl_config.bat
4 | Line: 21
5 |
6 | Step 1: Change value of key / value pair.
7 | Step 2: Run 'Test 15'
8 | Step 3: Confirm failure.
9 | Step 4: Undo change made in step 1.
--------------------------------------------------------------------------------
/testing/Test 11 - Script - Apache Service Name Error.txt:
--------------------------------------------------------------------------------
1 | // Test failure when WampServer Apache service name can not be found.
2 |
3 | File: {WampServer Installation Path}\wampmanager.conf
4 | Section: [service]
5 | Key: ServiceApache
6 |
7 | Step 1: Change key of key / value pair.
8 | Step 2: Run 'Test 15'
9 | Step 3: Confirm failure.
10 | Step 4: Undo change made in step 1.
--------------------------------------------------------------------------------
/testing/Test 12 - WampServer - Apache Conf Validation Error.txt:
--------------------------------------------------------------------------------
1 | // Test failure when WampServer Apache configuration file contains an error.
2 |
3 | File: {WampServer Installation Path}\bin\apache\apacheX.X.XX\conf\httpd.conf
4 | Line: EOF (End Of File)
5 |
6 | Step 1: Add some random text to EOF.
7 | Step 2: Run 'Test 15'
8 | Step 3: Confirm failure.
9 | Step 4: Undo change made in step 1.
--------------------------------------------------------------------------------
/testing/Test 13 - Script - Restore 1 - Pass.bat:
--------------------------------------------------------------------------------
1 | rem Test successful execution with 'restore' command as first argument.
2 |
3 | call "../ssl_config.bat" restore "../testing/configs/config.ini"
--------------------------------------------------------------------------------
/testing/Test 14 - Script - Restore 2 - Pass.bat:
--------------------------------------------------------------------------------
1 | rem Test successful execution with 'restore' command as second argument.
2 |
3 | call "../ssl_config.bat" "../testing/configs/config.ini" restore
--------------------------------------------------------------------------------
/testing/Test 15 - Script - Pass.bat:
--------------------------------------------------------------------------------
1 | Rem Test successful execution.
2 |
3 | call "../ssl_config.bat" "../testing/configs/config.ini"
--------------------------------------------------------------------------------
/testing/Test 2 - CLI - More Than 2 Arguments.bat:
--------------------------------------------------------------------------------
1 | rem Test failure when more than 2 CLI arguments given.
2 |
3 | call "../ssl_config.bat" "configs/config.ini" "arg2" "arg3"
--------------------------------------------------------------------------------
/testing/Test 3 - CLI - Argument Not Recognised.bat:
--------------------------------------------------------------------------------
1 | Rem Test failure when unknown CLI argument given.
2 |
3 | call "../ssl_config.bat" "configs/config.ini" "unknown-arg"
--------------------------------------------------------------------------------
/testing/Test 4 - CLI - Must Have Ini Extension.bat:
--------------------------------------------------------------------------------
1 | Rem Test failure when configuration file extension if not '.ini'
2 |
3 | call "../ssl_config.bat" "configs/config.xml"
--------------------------------------------------------------------------------
/testing/Test 5 - CLI - Path Invalid.bat:
--------------------------------------------------------------------------------
1 | rem Test failure when given an invalid config.ini path.
2 |
3 | call "../ssl_config.bat" "configs/unknown-path/config.ini"
--------------------------------------------------------------------------------
/testing/Test 6 - Config - Section Corrupt.bat:
--------------------------------------------------------------------------------
1 | rem Test failure when [section] line in config.ini is corrupt.
2 |
3 | call "../ssl_config.bat" "configs/config-section-corrupt.ini"
--------------------------------------------------------------------------------
/testing/Test 7 - Config - Key Value Pair Corrupt.bat:
--------------------------------------------------------------------------------
1 | rem Test failure when key / value pair in config.ini is corrupt.
2 |
3 | call "../ssl_config.bat" "configs/config-key-value-pair-corrupt.ini"
--------------------------------------------------------------------------------
/testing/Test 8 - Config - WampServer Install Path Corrupt.bat:
--------------------------------------------------------------------------------
1 | rem Test failure when value of WampServer installation path in config.ini is corrupt.
2 |
3 | call "../ssl_config.bat" "configs/config-wampserver-install-path-corrupt.ini"
--------------------------------------------------------------------------------
/testing/Test 9 - Script - Apache Sub path Corrupt.txt:
--------------------------------------------------------------------------------
1 | // Test failure when WampServer Apache sub path is corrupt.
2 |
3 | File: ssl_config.bat
4 | Line: 14
5 |
6 | Step 1: Change value of key / value pair.
7 | Step 2: Run 'Test 15'
8 | Step 3: Confirm failure.
9 | Step 4: Undo change made in step 1.
--------------------------------------------------------------------------------
/testing/configs/config-key-value-pair-corrupt.ini:
--------------------------------------------------------------------------------
1 | ;--------------------------;
2 | ; WampServer Configuration ;
3 | ;--------------------------;
4 |
5 | ; Your WampServer installation path.
6 | wampServerInstallPath=C:\wamp64
7 |
8 | ; The parent path where your SSL certificates, keys, vhost and log files will be stored.
9 | wampServerExtensionsPath=C:\wamp64 - ssl auto config
10 |
11 | ;-------------------------;
12 | ; SSL Certificate Details ;
13 | ;-------------------------;
14 |
15 | ; These (common) ssl certificate details are used to build each development domain name's certificate.
16 | ;
17 | ; sslCity: The full name of a city.
18 | ; sslState: The full name of a state.
19 | ; sslCountry: The two letter ISO code of a country.
20 | ; sslOrganisation: The organisation name.
21 | ; sslOrganisationUnit: The unit name of a organisation.
22 | ; sslEmail: Use the local part of an email address followed by the @ (at) symbol only.
23 | ; IMPORTANT: Do not include the domain part of the email address as the hostname will be auto-appended.
24 | ; sslDays: The number of days you would like the certificates to remain valid for.
25 |
26 | sslCity=Brisbane
27 | sslState=Queensland
28 | sslCountry=AU
29 | sslOrganization=Business
30 | sslOrganizationUnit=IT Department
31 | sslEmail=webmaster@
32 | sslDays=3650
33 |
34 | ;---------------------;
35 | ; Development Domains ;
36 | ;---------------------;
37 |
38 | [Website 1]
39 | hostname
40 | documentRoot=C:/wamp64 - domains/website-1/public_html
41 | http2=true
42 |
43 | [Website 2]
44 | hostname=www.dev.website-2.com.au
45 | documentRoot=C:/wamp64 - domains/website-2/public_html
46 | http2=true
--------------------------------------------------------------------------------
/testing/configs/config-section-corrupt.ini:
--------------------------------------------------------------------------------
1 | ;--------------------------;
2 | ; WampServer Configuration ;
3 | ;--------------------------;
4 |
5 | ; Your WampServer installation path.
6 | wampServerInstallPath=C:\wamp64
7 |
8 | ; The parent path where your SSL certificates, keys, vhost and log files will be stored.
9 | wampServerExtensionsPath=C:\wamp64 - ssl auto config
10 |
11 | ;-------------------------;
12 | ; SSL Certificate Details ;
13 | ;-------------------------;
14 |
15 | ; These (common) ssl certificate details are used to build each development domain name's certificate.
16 | ;
17 | ; sslCity: The full name of a city.
18 | ; sslState: The full name of a state.
19 | ; sslCountry: The two letter ISO code of a country.
20 | ; sslOrganisation: The organisation name.
21 | ; sslOrganisationUnit: The unit name of a organisation.
22 | ; sslEmail: Use the local part of an email address followed by the @ (at) symbol only.
23 | ; IMPORTANT: Do not include the domain part of the email address as the hostname will be auto-appended.
24 | ; sslDays: The number of days you would like the certificates to remain valid for.
25 |
26 | sslCity=Brisbane
27 | sslState=Queensland
28 | sslCountry=AU
29 | sslOrganization=Business
30 | sslOrganizationUnit=IT Department
31 | sslEmail=webmaster@
32 | sslDays=3650
33 |
34 | ;---------------------;
35 | ; Development Domains ;
36 | ;---------------------;
37 |
38 | [Website 1] ___this should not be here___
39 | hostname=www.dev.website-1.com.au
40 | documentRoot=C:/wamp64 - domains/website-1/public_html
41 | http2=true
42 |
43 | [Website 2]
44 | hostname=www.dev.website-2.com.au
45 | documentRoot=C:/wamp64 - domains/website-2/public_html
46 | http2=true
--------------------------------------------------------------------------------
/testing/configs/config-wampserver-install-path-corrupt.ini:
--------------------------------------------------------------------------------
1 | ;--------------------------;
2 | ; WampServer Configuration ;
3 | ;--------------------------;
4 |
5 | ; Your WampServer installation path.
6 | wampServerInstallPath=C:\wrong\wamp64
7 |
8 | ; The parent path where your SSL certificates, keys, vhost and log files will be stored.
9 | wampServerExtensionsPath=C:\wamp64 - ssl auto config
10 |
11 | ;-------------------------;
12 | ; SSL Certificate Details ;
13 | ;-------------------------;
14 |
15 | ; These (common) ssl certificate details are used to build each development domain name's certificate.
16 | ;
17 | ; sslCity: The full name of a city.
18 | ; sslState: The full name of a state.
19 | ; sslCountry: The two letter ISO code of a country.
20 | ; sslOrganisation: The organisation name.
21 | ; sslOrganisationUnit: The unit name of a organisation.
22 | ; sslEmail: Use the local part of an email address followed by the @ (at) symbol only.
23 | ; IMPORTANT: Do not include the domain part of the email address as the hostname will be auto-appended.
24 | ; sslDays: The number of days you would like the certificates to remain valid for.
25 |
26 | sslCity=Brisbane
27 | sslState=Queensland
28 | sslCountry=AU
29 | sslOrganization=Business
30 | sslOrganizationUnit=IT Department
31 | sslEmail=webmaster@
32 | sslDays=3650
33 |
34 | ;---------------------;
35 | ; Development Domains ;
36 | ;---------------------;
37 |
38 | [Website 1]
39 | hostname=www.dev.website-1.com.au
40 | documentRoot=C:/wamp64 - domains/website-1/public_html
41 | http2=true
42 |
43 | [Website 2]
44 | hostname=www.dev.website-2.com.au
45 | documentRoot=C:/wamp64 - domains/website-2/public_html
46 | http2=true
--------------------------------------------------------------------------------
/testing/configs/config.ini:
--------------------------------------------------------------------------------
1 | ;--------------------------;
2 | ; WampServer Configuration ;
3 | ;--------------------------;
4 |
5 | ; Your WampServer installation path.
6 | wampServerInstallPath=C:\wamp64
7 |
8 | ; The parent path where your SSL certificates, keys, vhost and log files will be stored.
9 | wampServerExtensionsPath=C:\wamp64 - ssl auto config
10 |
11 | ;-------------------------;
12 | ; SSL Certificate Details ;
13 | ;-------------------------;
14 |
15 | ; These (common) ssl certificate details are used to build each development domain name's certificate.
16 | ;
17 | ; sslCity: The full name of a city.
18 | ; sslState: The full name of a state.
19 | ; sslCountry: The two letter ISO code of a country.
20 | ; sslOrganisation: The organisation name.
21 | ; sslOrganisationUnit: The unit name of a organisation.
22 | ; sslEmail: Use the local part of an email address followed by the @ (at) symbol only.
23 | ; IMPORTANT: Do not include the domain part of the email address as the hostname will be auto-appended.
24 | ; sslDays: The number of days you would like the certificates to remain valid for.
25 |
26 | sslCity=Brisbane
27 | sslState=Queensland
28 | sslCountry=AU
29 | sslOrganization=Business
30 | sslOrganizationUnit=IT Department
31 | sslEmail=webmaster@
32 | sslDays=3650
33 |
34 | ;---------------------;
35 | ; Development Domains ;
36 | ;---------------------;
37 |
38 | [Website 1]
39 | hostname=www.dev.website-1.com.au
40 | documentRoot=C:/wamp64 - domains/website-1/public_html
41 |
42 | [Website 2]
43 | hostname=www.dev.website-2.com.au
44 | documentRoot=C:/wamp64 - domains/website-2/public_html
--------------------------------------------------------------------------------