Skip to content

Commit 08baaa9

Browse files
authored
Fixes and updates for local testing over HTTPS (#11768)
* Tweak how local cert is generated - Don't include port in CN - Add SAN including the IP address (required for Safari on iOS) [skip changelog] * Update docs for local development - Bind to a specific IP - Describe how to trust cert on iOS * Don't include port number in name of SSL cert files This will ensure new keys / certs are generated without requiring folks to remove the old ones first.
1 parent 58ccf84 commit 08baaa9

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed

Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,18 @@ test_serial: export RAILS_ENV := test
207207
test_serial: $(CONFIG) ## Runs RSpec and yarn tests serially
208208
bundle exec rake spec && yarn test
209209

210-
tmp/$(HOST)-$(PORT).key tmp/$(HOST)-$(PORT).crt: ## Self-signed cert for local HTTPS development
210+
tmp/$(HOST).key tmp/$(HOST).crt: ## Self-signed cert for local HTTPS development
211211
mkdir -p tmp
212212
openssl req \
213213
-newkey rsa:2048 \
214214
-x509 \
215215
-sha256 \
216216
-nodes \
217217
-days 365 \
218-
-subj "/C=US/ST=District of Columbia/L=Washington/O=GSA/OU=Login.gov/CN=$(HOST):$(PORT)" \
219-
-keyout tmp/$(HOST)-$(PORT).key \
220-
-out tmp/$(HOST)-$(PORT).crt
218+
-subj "/C=US/ST=District of Columbia/L=Washington/O=GSA/OU=Login.gov/CN=$(HOST)" \
219+
-addext "subjectAltName=IP:$(HOST)" \
220+
-keyout tmp/$(HOST).key \
221+
-out tmp/$(HOST).crt
221222

222223
run: browsers.json ## Runs the development server
223224
foreman start -p $(PORT)
@@ -226,8 +227,8 @@ urn:
226227
@echo "⚱️"
227228
make run
228229

229-
run-https: tmp/$(HOST)-$(PORT).key tmp/$(HOST)-$(PORT).crt ## Runs the development server with HTTPS
230-
HTTPS=on FOREMAN_HOST="ssl://$(HOST):$(PORT)?key=tmp/$(HOST)-$(PORT).key&cert=tmp/$(HOST)-$(PORT).crt" foreman start -p $(PORT)
230+
run-https: tmp/$(HOST).key tmp/$(HOST).crt ## Runs the development server with HTTPS
231+
HTTPS=on FOREMAN_HOST="ssl://$(HOST):$(PORT)?key=tmp/$(HOST).key&cert=tmp/$(HOST).crt" foreman start -p $(PORT)
231232

232233
normalize_yaml: ## Normalizes YAML files (alphabetizes keys, fixes line length, smart quotes)
233234
yarn normalize-yaml .rubocop.yml --disable-sort-keys --disable-smart-punctuation

docs/mobile.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,63 @@ Instructions to use an iPhone or Android mobile device for local app development
99

1010
These instructions will configure your local copy of the identity-idp app to serve web pages over your local computer network — the wifi in your home or office. You can broadcast the app to a mobile phone or tablet. Both your mobile device and your development computer (your laptop) must be connected to the same wifi network.
1111

12-
By default, the application binds to `localhost`. These instructions bind to `0.0.0.0` instead. Some Android users report they can access `localhost:3000` directly on their phone, however.
12+
By default, the application binds to `localhost`. To access it from a mobile device on the same network, you will need to bind it to an accessible IP address.
1313

14-
1. Find your Local Area Network IP address. On a MacBook, this is available at **System Preferences → Network**. The address may start with `192.168`.
14+
1. Find your Local Area Network IP address. On a MacBook, this is available at **System Preferences → Network**. The IP address you are looking for likely starts with `192.168.` or `10.`
1515

1616
2. In your app's `application.yml` file, add the below. Be sure to indent these lines and include them in the `development:` section. Also, fill in your actual LAN IP address. The final line creates a **confirm now** link in place of email confirmation.
1717

1818
```yaml
1919
development:
20-
domain_name: 192.168.x.x:3000
21-
mailer_domain_name: 192.168.x.x:3000
20+
domain_name: <YOUR IP ADDRESS>:3000
21+
mailer_domain_name: <YOUR IP ADDRESS>:3000
2222
enable_load_testing_mode: true
2323
```
2424
2525
3. Start your app's local web server with:
2626
2727
```bash
28-
HOST=0.0.0.0 make run-https
28+
HOST=<YOUR IP ADDRESS> make run-https
2929
```
3030

3131
4. On your phone's browser, open a new tab. In the address bar, type in `https://` (don't forget the `s`) followed by your LAN IP and port number (like `https://192.168.x.x:3000`). When you visit this page, you may see a **Your connection is not private** message. Click **Advanced** and **Proceed** to continue. You should then see the sign in screen of the identity-idp app.
3232

3333
After you complete these steps, pages from the app are served from your development machine to your mobile device, where you may now use the identity-idp app. For front-end development, you may now want to turn on browser development tools per the next section of these instructions.
3434

35+
### Special instructions for iOS
36+
37+
It is becoming more common for browsers to entirely block access to sites using self-signed certificates, not even providing an escape hatch like the one described above.
38+
39+
If you are not able to access the locally running app from your iPhone, follow these steps:
40+
41+
#### 1. Somehow get the `.crt` file into the iOS Files app
42+
43+
When you run `make run-https`, the system generates a self-signed SSL certificate for you and stores it in the `tmp` directory. The file will be named something like `<YOUR IP ADDRESS>-3000.crt`. You need to get that file onto your phone and into the iOS Files app.
44+
45+
One way to do this is via Google Drive:
46+
47+
1. Upload the file to Google Drive.
48+
2. Open the Google Drive app on your phone and "Download" the `.crt` file.
49+
3. When prompted for a destination, select "Save to Files".
50+
51+
#### 2. Import the certificate into iOS
52+
53+
1. Open the Files app.
54+
2. Tap on the `.crt` file (fun fact: it may now show a `.cer` extension!).
55+
3. You should see some kind of message about a profile being downloaded.
56+
4. Open the Settings app. Notice you have a new "Profile Downloaded" item there. Tap that.
57+
5. Install the profile. You will be prompted for confirmation many times.
58+
59+
#### 3. Trust the certificate
60+
61+
1. Go to **Settings > General > About > Certificate Trust Settings**.
62+
2. Tick the little box next to the certificate you just installed.
63+
64+
At this point, you _should_ be able to access the IdP running on your local development computer from your phone.
65+
66+
> [!WARNING]
67+
> Do not forget to un-trust the certificate and remove the profile when you are done.
68+
3569
## Debugging with the desktop browser
3670

3771
After you have completed the [§ Use the app from a mobile device](#use-the-app-from-a-mobile-device) instructions above, you may further want to use your desktop browser's development and dubugging tools.

0 commit comments

Comments
 (0)