CSR
application/octet-stream
Magic Bytes
Offset: 0
2D 2D 2D 2D 2D 42 45 47 49 4E 20 43 45 52 54 49 46 49 43 41 54 45 20 52 45 51 55 45 53 54 2D 2D 2D 2D 2D
A Certificate Signing Request (CSR) is a standardized data format defined by the PKCS #10 specification, developed by RSA Security and maintained by the IETF. Administrators utilize these files to submit public keys and organizational details to a Certificate Authority for SSL/TLS certificate issuance. Because CSRs contain only public information and digital signatures, they pose no execution risk and serve as the fundamental mechanism for establishing secure, authenticated identities across public key infrastructures.
Validation Code
How to validate .csr files in Python
Python
def is_csr(file_path: str) -> bool:
"""Check if file is a valid CSR by magic bytes."""
signature = bytes([0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x20, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D])
with open(file_path, "rb") as f:
return f.read(35) == signature
How to validate .csr files in Node.js
Node.js
function isCSR(buffer: Buffer): boolean {
const signature = Buffer.from([0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x20, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D]);
return buffer.subarray(0, 35).equals(signature);
}
Go
func IsCSR(data []byte) bool {
signature := []byte{0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x43, 0x45, 0x52, 0x54, 0x49, 0x46, 0x49, 0x43, 0x41, 0x54, 0x45, 0x20, 0x52, 0x45, 0x51, 0x55, 0x45, 0x53, 0x54, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D}
if len(data) < 35 {
return false
}
return bytes.Equal(data[:35], signature)
}
API Endpoint
GET
/api/v1/csr
curl https://filesignature.org/api/v1/csr