spiegel-keyman/resources/devbox/iis-https/setup-iis-https.sh
Marc Durdin 0d4a6e428a fix(windows): base layout support in Keyman Core
While Keyman Core already supported the base layout flags, they were not
being passed in from Keyman Engine for Windows. This meant that any
rules that used `baselayout` would fail, such as in sil_ipa with AltGr+0
for }

0bf72bed74/release/sil/sil_ipa/source/sil_ipa.kmn (L348-L350)

This patch adds support for the following properties:

* KM_KBP_KMX_ENV_BASELAYOUT: the legacy base layout name, e.g. kbdus.dll
* KM_KBP_KMX_ENV_BASELAYOUTALT: the BCP 47 base layout name, e.g. en-US
* KM_KBP_KMX_ENV_SIMULATEALTGR: whether the user has selected to emulate
  AltGr with Ctrl+Alt, for example on laptops without a right alt key.
* KM_KBP_KMX_ENV_BASELAYOUTGIVESCTRLRALTFORRALT: whether the system base
  layout in use generates Ctrl+RAlt when RAlt is pressed, which can be
  true for many European system layouts. This is necessary when
  associating the keyboard with a European language because the base
  keyboard becomes the language's default keyboard, rather than kbdus.
2022-11-14 12:27:04 +11:00

111 lines
3.9 KiB
Bash
Executable file

#!/usr/bin/env bash
set -e
set -u
## START STANDARD BUILD SCRIPT INCLUDE
# adjust relative paths as necessary
THIS_SCRIPT="$(greadlink -f "${BASH_SOURCE[0]}" 2>/dev/null || readlink -f "${BASH_SOURCE[0]}")"
. "$(dirname "$THIS_SCRIPT")/../../build/build-utils.sh"
## END STANDARD BUILD SCRIPT INCLUDE
. "$KEYMAN_ROOT/resources/shellHelperFunctions.sh"
echo_heading2() {
echo ""
echo_heading "$*"
}
get_builder_OS
if [ $os_id != win ]; then
fail "This script can only be run on Windows to setup IIS."
fi
warn "Warning: this script requires Administrator permissions to install certificates."
# Generate CA key
echo_heading2 "Generating CA key"
if [ ! -f rootCA.key ]; then
echo "Please create a password for the certification authority key"
echo "This should be unique to your setup."
winpty openssl genrsa -des3 -out rootCA.key 2048
else
echo "Skipping, rootCA.key already present"
fi
# Generate CA certificate
echo_heading2 "Generating CA certificate"
if [ ! -f rootCA.pem ]; then
winpty openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 3650 -out rootCA.pem
else
echo "Skipping, rootCA.pem already present"
fi
# Generate site certificate signing request
echo_heading2 "Generating site certificate signing request"
if [ ! -f server.csr ]; then
winpty openssl req -new -sha256 -nodes -out server.csr -newkey rsa:2048 -keyout server.key -config server.csr.cnf
else
echo "Skipping, server.csr already present"
fi
# Generate site certificate
echo_heading2 "Generating site certificate"
if [ ! -f server.crt ]; then
winpty openssl x509 -req -in server.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out server.crt -days 500 -sha256 -extfile v3.ext
else
echo "Skipping, server.crt already present"
fi
# Convert site certificate to .pfx for IIS
echo_heading2 "Converting certificate to .pfx for IIS"
if [ ! -f server.pfx ]; then
winpty openssl pkcs12 -export -out server.pfx -inkey server.key -in server.crt
else
echo "Skipping, server.pfx already present"
fi
# Import the CA certificate into the Trusted Root Certification Authorities
echo_heading2 "Importing CA certificate to root store"
certutil -addstore Root rootCA.pem
# Import server.pfx to IIS certficate store
echo_heading2 "Importing site certificate to WebHosting store"
certutil -importPFX WebHosting server.pfx
# Add bindings to each site in IIS
echo_heading2 "Setup IIS bindings"
echo "Now, add a HTTPS binding for each site in IIS (this is painful to automate):"
echo "1. Open IIS Manager"
echo "2. For each site, click Bindings in Actions panel"
echo "3. Click Add:"
echo " Select Type='https'"
echo " Select Host name=per the existing binding (e.g. 'keymanweb.com.local')"
echo " Select SSL certificate='keyman.com.local'"
echo "4. Click OK, Close, and repeat for each site."
echo ""
echo "This certificate can be used for all keyman.com sites and localhost; see"
echo "README.md / v3.ext for list of matching domains."
# Update PHP CACert
echo_heading2 "Setup PHP certificate authority"
curl -s https://curl.se/ca/cacert.pem > cacert.pem
echo "" >> cacert.pem
echo "Keyman Localhost CA" >> cacert.pem
echo "===================" >> cacert.pem
echo "## This is a local CA for Keyman localhost websites generated by" >> cacert.pem
echo "## https://github.com/keymanapp/keyman/tree/master/build/devbox/iis-https/setup-iis-https.sh" >> cacert.pem
cat rootCA.pem >> cacert.pem
echo "We also need to add our CA certificate to PHP so we can access our local"
echo "https sites from PHP scripts."
echo "1. Locate php.ini (e.g. C:\\tools\\php74\\php.ini)"
echo "2. Copy cacert.pem from here and save it alongside your PHP.ini file"
echo "3. Set curl.cainfo and openssl.cafile in php.ini to cacert.pem location, e.g."
echo " curl.cainfo = \"C:\\tools\\php74\\cacert.pem\""
echo "4. Finally, you may need to restart IIS for changes to take effect."
echo_heading2 "Complete"
warn "Please check logs above for errors and manual steps"