Skip to content

Commit 4875066

Browse files
committed
Fix BoringSSL compatibility for Bun runtime
Bun uses BoringSSL which requires an explicit digest algorithm for EC key signing, but the ephemeral signer was using crypto.sign(null, ...) which only works with Node's OpenSSL implementation. Changes: - Updated ephemeral signer to use 'sha256' explicitly instead of null - Changed from default crypto import to named imports for better compatibility - Both Node.js (OpenSSL) and Bun (BoringSSL) now work correctly This enables Bun users to use @sigstore/sign without any patches or workarounds. Signed-off-by: keithagroves <[email protected]>
1 parent eba6a52 commit 4875066

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sigstore/sign': patch
3+
---
4+
5+
Fix BoringSSL compatibility for Bun runtime. The ephemeral signer now explicitly uses SHA-256 as the digest algorithm instead of relying on implicit defaults, enabling @sigstore/sign to work with Bun's BoringSSL implementation.

packages/sign/src/signer/fulcio/ephemeral.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
import crypto, { KeyPairKeyObjectResult } from 'crypto';
16+
import { generateKeyPairSync, sign, KeyPairKeyObjectResult } from 'crypto';
1717

1818
import type { Signature, Signer } from '../signer';
1919

@@ -27,13 +27,13 @@ export class EphemeralSigner implements Signer {
2727
private keypair: KeyPairKeyObjectResult;
2828

2929
constructor() {
30-
this.keypair = crypto.generateKeyPairSync(EC_KEYPAIR_TYPE, {
30+
this.keypair = generateKeyPairSync(EC_KEYPAIR_TYPE, {
3131
namedCurve: P256_CURVE,
3232
});
3333
}
3434

3535
public async sign(data: Buffer): Promise<Signature> {
36-
const signature = crypto.sign(null, data, this.keypair.privateKey);
36+
const signature = sign('sha256', data, this.keypair.privateKey);
3737
const publicKey = this.keypair.publicKey
3838
.export({ format: 'pem', type: 'spki' })
3939
.toString('ascii');

0 commit comments

Comments
 (0)