asyx 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/package.json +1 -1
- package/src/lib/csr.js +32 -12
package/README.md
CHANGED
|
@@ -92,6 +92,28 @@ The CLI manages heartbeats automatically to keep idle sessions stable without us
|
|
|
92
92
|
- Heartbeat stops when the tunnel exits or errors.
|
|
93
93
|
- Use `ASYX_DEBUG=1` if you need to trace heartbeat activity for support purposes.
|
|
94
94
|
|
|
95
|
+
## Troubleshooting
|
|
96
|
+
|
|
97
|
+
### MQTT Connection Issues (Windows)
|
|
98
|
+
|
|
99
|
+
If you experience issues where the CLI connects but never receives `open_ack` messages (especially on Windows after running `asyx setup` without OpenSSL), the private key may be in PKCS#8 format which Node's TLS stack on Windows rejects.
|
|
100
|
+
|
|
101
|
+
**Solution**: Rerun `asyx setup` to regenerate keys in the correct format. The CLI will automatically convert existing PKCS#8 keys to PKCS#1 format (required for Windows TLS compatibility).
|
|
102
|
+
|
|
103
|
+
**Manual workaround** (if you cannot rerun setup):
|
|
104
|
+
```javascript
|
|
105
|
+
const crypto = require('crypto');
|
|
106
|
+
const fs = require('fs');
|
|
107
|
+
const keyPath = '~/.asyx/certs/<clientId>/private.pem.key';
|
|
108
|
+
|
|
109
|
+
const keyPem = fs.readFileSync(keyPath, 'utf8');
|
|
110
|
+
const privateKey = crypto.createPrivateKey({ key: keyPem, format: 'pem' });
|
|
111
|
+
const pkcs1Pem = privateKey.export({ type: 'pkcs1', format: 'pem' });
|
|
112
|
+
fs.writeFileSync(keyPath, pkcs1Pem, { mode: 0o600 });
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
This issue is fixed in version 0.1.2+ where keys are automatically generated in PKCS#1 format for Windows compatibility.
|
|
116
|
+
|
|
95
117
|
## Security
|
|
96
118
|
|
|
97
119
|
Asyx tunnels are designed with security-first principles to protect both your local services and the tunnel infrastructure. Every active tunnel operates with **per-tunnel cryptographic isolation**, short-lived JWT credentials, and in-band credential refresh to achieve zero-downtime, zero-trust operation.
|
package/package.json
CHANGED
package/src/lib/csr.js
CHANGED
|
@@ -127,12 +127,23 @@ export async function ensureKeyAndCsr(clientId, options = {}) {
|
|
|
127
127
|
// Generate new key pair
|
|
128
128
|
keyPair = await crypto.subtle.generateKey(alg, true, ['sign', 'verify']);
|
|
129
129
|
|
|
130
|
-
// Export private key in
|
|
130
|
+
// Export private key in PKCS#8 format (for CSR operations)
|
|
131
131
|
const pkcs8 = await crypto.subtle.exportKey('pkcs8', keyPair.privateKey);
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
|
|
132
|
+
const pkcs8Pem = bufferToPem(pkcs8, 'PRIVATE KEY');
|
|
133
|
+
|
|
134
|
+
// Convert PKCS#8 to PKCS#1 using Node.js crypto (required for Windows TLS compatibility)
|
|
135
|
+
// Node's TLS stack on Windows requires PKCS#1 format (BEGIN RSA PRIVATE KEY)
|
|
136
|
+
const nodePrivateKey = nodeCrypto.createPrivateKey({
|
|
137
|
+
key: pkcs8Pem,
|
|
138
|
+
format: 'pem'
|
|
139
|
+
});
|
|
140
|
+
const pkcs1Pem = nodePrivateKey.export({
|
|
141
|
+
type: 'pkcs1',
|
|
142
|
+
format: 'pem'
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Write private key file in PKCS#1 format (for TLS compatibility)
|
|
146
|
+
await fs.writeFile(keyPath, pkcs1Pem, { encoding: 'utf8', mode: 0o600 });
|
|
136
147
|
} else {
|
|
137
148
|
// Import existing private key
|
|
138
149
|
const keyPem = await fs.readFile(keyPath, 'utf8');
|
|
@@ -141,24 +152,33 @@ export async function ensureKeyAndCsr(clientId, options = {}) {
|
|
|
141
152
|
const isPkcs1 = keyPem.includes('BEGIN RSA PRIVATE KEY');
|
|
142
153
|
|
|
143
154
|
let pkcs8Bytes;
|
|
155
|
+
|
|
144
156
|
if (isPkcs1) {
|
|
145
|
-
//
|
|
146
|
-
//
|
|
157
|
+
// Key is already PKCS#1 - keep it as is (don't convert to PKCS#8)
|
|
158
|
+
// Convert PKCS#1 to PKCS#8 bytes in memory for webcrypto import
|
|
147
159
|
const nodePrivateKey = nodeCrypto.createPrivateKey({
|
|
148
160
|
key: keyPem,
|
|
149
161
|
format: 'pem'
|
|
150
162
|
});
|
|
151
|
-
// Export in PKCS#8 format
|
|
152
163
|
const pkcs8Pem = nodePrivateKey.export({
|
|
153
164
|
type: 'pkcs8',
|
|
154
165
|
format: 'pem'
|
|
155
166
|
});
|
|
156
167
|
pkcs8Bytes = pemToBuffer(pkcs8Pem);
|
|
157
|
-
//
|
|
158
|
-
await fs.writeFile(keyPath, pkcs8Pem, { encoding: 'utf8', mode: 0o600 });
|
|
168
|
+
// Keep file as PKCS#1 (no write needed)
|
|
159
169
|
} else {
|
|
160
|
-
//
|
|
161
|
-
|
|
170
|
+
// Key is PKCS#8 - convert to PKCS#1 for Windows TLS compatibility
|
|
171
|
+
const nodePrivateKey = nodeCrypto.createPrivateKey({
|
|
172
|
+
key: keyPem,
|
|
173
|
+
format: 'pem'
|
|
174
|
+
});
|
|
175
|
+
const pkcs1Pem = nodePrivateKey.export({
|
|
176
|
+
type: 'pkcs1',
|
|
177
|
+
format: 'pem'
|
|
178
|
+
});
|
|
179
|
+
pkcs8Bytes = pemToBuffer(keyPem); // Use original PKCS#8 for webcrypto
|
|
180
|
+
// Update the file to PKCS#1 format for future runs
|
|
181
|
+
await fs.writeFile(keyPath, pkcs1Pem, { encoding: 'utf8', mode: 0o600 });
|
|
162
182
|
}
|
|
163
183
|
|
|
164
184
|
keyPair = await importPrivateKey(pkcs8Bytes);
|