@kyanny's blog

My thoughts, my life. Views/opinions are my own.

PEM を分割する

split -d -p "BEGIN CERTIFICATE" collection.pem pem-

$ cat ssl.crt
-----BEGIN CERTIFICATE-----
MIIFJTCCBA2gAwIBAgISBDQTF4tkOl1xOEFjwYVzvtpGMA0GCSqGSIb3DQEBCwUA
MDIxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MQswCQYDVQQD
EwJSMzAeFw0yMzA4MDIwMDI1NTJaFw0yMzEwMzEwMDI1NTFaMCcxJTAjBgNVBAMT
HGt5YW5ueS0xNjkwOTM5MDQ5LnFhYm9vdC5uZXQwggEiMA0GCSqGSIb3DQEBAQUA
A4IBDwAwggEKAoIBAQCXNXXtaLl6jsyiUMGTWBOfCpwv5G7znkFyAatUkhmo6yfd
+v+LX20Iisl76022fDwjf3ZYOXGQuticZ+yrB9eeDsgvQDuppXB0BHHQmr1Oe+O1
rrO6iNntTi3iLmRa08CU8V5gNe3LWQ0iwUU2ZCUDVos5G1kLFJwbmPdVuqk/pfZ9
hJajxkCnyE75HKf9VvA/YHcDvknB3qXfDdqQb3uq4P2h7hOe/oH+iMCZXiML0OAG
XczWtuJvcemFSiNHHmNC3eHAnTKCBEnSo1kgjC1MJbanUvVJ0H/GJpEwYnshP9a7
1yMZp3J64wKXRDF8F3pp0zsuBy8XNkw9xKUh2UDDAgMBAAGjggI+MIICOjAOBgNV
HQ8BAf8EBAMCBaAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMAwGA1Ud
EwEB/wQCMAAwHQYDVR0OBBYEFCw5T1pV8oWTDLBVf7Z815J3BS4XMB8GA1UdIwQY
MBaAFBQusxe3WFbLrlAJQOYfr52LFMLGMFUGCCsGAQUFBwEBBEkwRzAhBggrBgEF
BQcwAYYVaHR0cDovL3IzLm8ubGVuY3Iub3JnMCIGCCsGAQUFBzAChhZodHRwOi8v
cjMuaS5sZW5jci5vcmcvMEcGA1UdEQRAMD6CHioua3lhbm55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CnbWSDtY7kh+BIm
lJNXoB1lBMEKIq4QDUOXoRgffuDghje1WrG9ML+Hbisq/yFOGwXD9RiX8F6sw6W4
avAuvDszue5L3sz85K+EC4Y/wFVDNvZo4TYXao6Z0f+lQKc0t8DQYzk1OXVu8rp2
yJMC6alLbBfODALZvYH7n7do1AZls4I9d1P4jnkDrQoxB3UqQ9hVl3LEKQ73xF1O
yK5GhDDX8oVfGKF5u+decIsH4YaTw7mP3GFxJSqv3+0lUFJoi5Lc5da149p90Ids
hCExroL1+7mryIkXPeFM5TgO9r0rvZaBFOvV2z0gp35Z0+L4WPlbuEjN/lxPFin+
HlUjr8gRsI3qfJOQFy/9rKIJR0Y/8Omwt/8oTWgy1mdeHmmjk7j1nYsvC9JSQ6Zv
MldlTTKB3zhThV1+XWYp6rjd5JW1zbVWEkLNxE7GJThEUG3szgBVGP7pSWTUTsqX
nLRbwHOoq7hHwg==
-----END CERTIFICATE-----
$ split -d -p "BEGIN CERTIFICATE" ssl.crt pem-

$ ls pem-*
pem-00  pem-01

$ openssl x509 -in pem-00 -serial -dates -issuer -subject -noout
serial=043413178B643A5D71384163C18573BEDA46
notBefore=Aug  2 00:25:52 2023 GMT
notAfter=Oct 31 00:25:51 2023 GMT
issuer=C = US, O = Let's Encrypt, CN = R3
subject=CN = kyanny-1690939049.qaboot.net

$ openssl x509 -in pem-01 -serial -dates -issuer -subject -noout
serial=912B084ACF0C18A753F6D62E25A75F5A
notBefore=Sep  4 00:00:00 2020 GMT
notAfter=Sep 15 16:00:00 2025 GMT
issuer=C = US, O = Internet Security Research Group, CN = ISRG Root X1
subject=C = US, O = Let's Encrypt, CN = R3