-
Notifications
You must be signed in to change notification settings - Fork 3
feat(PE-1060): Reference example for handling self signed certs players that support RED compliance #99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
feat(PE-1060): Reference example for handling self signed certs players that support RED compliance #99
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Self-Signed Certificate Handling Example | ||
|
|
||
| ## Introduction | ||
|
|
||
| This example demonstrates how to handle self-signed certificates when communicating with BrightSign players via the local Diagnostic Web Server (DWS). BrightSign players use self-signed certificates for HTTPS communication, which requires configuring your HTTP client to accept these certificates for successful player communication and management. | ||
|
|
||
| ## How it Works | ||
|
|
||
| 1. **Certificate Generation**: BrightSign players automatically generate self-signed certificates for secure HTTPS communication | ||
| 2. **Client Configuration**: Standard HTTP clients reject self-signed certificates by default for security reasons | ||
| 3. **Agent Setup**: The example creates an HTTPS agent with `rejectUnauthorized: false` to accept self-signed certificates | ||
| 4. **API Communication**: Uses the configured agent to make secure requests to the player's DWS endpoints | ||
|
|
||
| ## How to Run the Example | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| 1. **Node.js Environment**: Ensure you have Node.js installed on your development machine | ||
jdmedlin1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 2. **Network Connection**: Your computer and BrightSign player should be on the same network | ||
| 3. **Player IP Address**: Know the IP address of your BrightSign player | ||
jdmedlin1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Steps to Run | ||
|
|
||
| 1. **Install Dependencies**: | ||
| ```bash | ||
| npm install undici | ||
jdmedlin1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| 2. **Update Player IP**: | ||
| - Open `index.js` | ||
| - Replace `192.168.1.100` with your player's actual IP address | ||
|
|
||
| 3. **Run the Example**: | ||
| ```bash | ||
| node index.js | ||
| ``` | ||
|
|
||
| 4. **Expected Output**: | ||
| - If successful, you'll see the player's status response in JSON format | ||
| - Any communication errors will be displayed with descriptive error messages | ||
|
|
||
| ## Files Structure | ||
jdmedlin1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - **index.js**: Main example file showing how to configure undici Agent for self-signed certificates | ||
| - **README.md**: This documentation file | ||
|
|
||
| ## Important Security Notes | ||
|
|
||
| - Only disable certificate verification (`rejectUnauthorized: false`) for trusted BrightSign player communication | ||
| - Never use this configuration for external or untrusted HTTPS endpoints | ||
| - This approach is specifically designed for local development and player management scenarios | ||
| - Default DWS port is `8443` for HTTPS communication | ||
jdmedlin1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| const { Agent } = require('undici'); | ||
|
|
||
| // Create an agent that accepts self-signed certificates | ||
| const httpsAgent = new Agent({ | ||
| connect: { | ||
| rejectUnauthorized: false, | ||
| }, | ||
| }); | ||
|
|
||
| // Example: Making a request to a BrightSign player with self-signed cert | ||
| async function communicateWithPlayer(playerIP, endpoint = '/api/v1/status') { | ||
| const url = `https://${playerIP}:8443${endpoint}`; | ||
|
|
||
| try { | ||
| const response = await fetch(url, { | ||
jdmedlin1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| dispatcher: httpsAgent | ||
| }); | ||
|
|
||
| const data = await response.json(); | ||
| console.log('Player response:', data); | ||
| return data; | ||
| } catch (error) { | ||
| console.error('Communication failed:', error.message); | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| // Usage example | ||
| if (require.main === module) { | ||
| const playerIP = '192.168.1.100'; // Replace with your player's IP | ||
| communicateWithPlayer(playerIP) | ||
| .then(data => console.log('Success:', data)) | ||
| .catch(err => console.error('Error:', err)); | ||
| } | ||
|
|
||
| module.exports = { httpsAgent, communicateWithPlayer }; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.