I need to save the content of a *.PEM
certificate in a SQL Server database. I plan to save it in a nvarchar()
column, but I'm not sure what length should I use.
I would appreciate any advice. If you have experience with saving pem files to a relational database that would be even better.
There is no upper limit on the size of an X.509 certificate file in DER. PEM takes DER and increases its size by 4/3. So no, there is no upper limit on the size of a PEM format certificate.
PrivateKeyInfo
structure is about another 6 bytes.So, that's about 1.1k.
PEM takes this and increases its size by 4/3, which means that it'll be about 1380 encoded bytes.
Add the -----BEGIN PRIVATE KEY-----
and -----END PRIVATE KEY-----
header and footer, and that's another 50 bytes, for a total of 1420 bytes. (If it's an encrypted private key, it'll be a bit bigger.) There is no upper bound per se, but a file containing a private key shouldn't be larger than about 2048 bytes if it uses any reasonable keysize.
So, for conclusion, defining the field as varchar(2048)
should be safe enough.
There's no maximum certificate/key/signature size, and certificates can have extensions.
To be honest, I would follow one of these limits defined by well known companies:
The new supported size of certificate configured in DER is 6144 bytes and PEM is 8192 bytes".
Minimum length of 1. Maximum length of 16384.
Minimum length of 1. Maximum length of 32768.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.