Skip to content

CSR (.csr)

.csr file signature | application/octet-stream

PEM encoded X.509Certificate Signing Request

Safe

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

Sources: Wikipedia

Extension

.csr

MIME Type

application/octet-stream

Byte Offset

0

Risk Level

Safe

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);
}

How to validate .csr files in Go

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

See the full API documentation for all endpoints and parameters.

Frequently Asked Questions

What is a .csr file?

A .csr file is a CSR file. PEM encoded X.509Certificate Signing Request

What are the magic bytes for .csr files?

The magic bytes for CSR files are 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 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .csr file?

To validate a .csr file, read the first bytes of the file and compare them against the known magic bytes (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) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .csr files?

There is no officially registered MIME type for .csr files. Systems typically use application/octet-stream as a generic fallback when handling this format.

Is it safe to open .csr files?

CSR (.csr) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.