Guest User

Untitled

a guest
Oct 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.13 KB | None | 0 0
  1. openssl x509 -text -in shttpd.pem
  2. Certificate:
  3. Data:
  4. Version: 3 (0x2)
  5. Serial Number:
  6. 86:22:84:0d:ba:09:d4:ca
  7. Signature Algorithm: sha1WithRSAEncryption
  8. Issuer: C=PL, ST=Some-State, O=Mini Webservice Ltd
  9. Validity
  10. Not Before: Sep 16 03:21:22 2008 GMT
  11. Not After : Sep 16 03:21:22 2009 GMT
  12. Subject: C=PL, ST=Some-State, O=Mini Webservice Ltd
  13. Subject Public Key Info:
  14. Public Key Algorithm: rsaEncryption
  15. Public-Key: (1024 bit)
  16. Modulus:
  17. 00:de:7e:0a:69:69:c7:06:f1:4b:3d:03:8b:45:dc:
  18. ab:63:39:f6:44:30:9b:7c:a8:c0:ff:1c:b9:4f:29:
  19. b1:1d:6b:ba:3d:16:7c:b1:bf:e8:67:d6:93:a4:f1:
  20. 68:b9:2c:44:e7:91:54:0c:cb:b2:ff:af:80:c3:83:
  21. aa:84:84:a7:f9:b9:d8:1d:1a:b2:42:72:2d:2f:fe:
  22. 71:0c:4a:02:0c:35:34:12:d5:2a:bc:de:e1:a3:4f:
  23. 3c:7b:9c:12:32:56:71:ae:af:bc:76:b6:e4:55:f4:
  24. 2f:df:ff:eb:c7:43:87:b0:40:81:80:1e:1d:d3:77:
  25. c9:66:50:ce:32:f2:f9:fa:a1
  26. Exponent: 65537 (0x10001)
  27. X509v3 extensions:
  28. Netscape Cert Type:
  29. SSL Server
  30. Signature Algorithm: sha1WithRSAEncryption
  31. 38:9e:5e:01:95:0c:7c:5c:4a:cd:57:e5:62:ee:50:90:7a:69:
  32. 9e:4a:6f:74:f5:ad:7b:7a:63:b6:ad:94:1a:c1:ff:23:f9:8d:
  33. 01:16:6c:62:c7:2d:bd:bb:54:ac:d5:43:a1:fe:60:8f:83:6a:
  34. 20:7a:05:57:6f:54:0e:a5:bc:3a:9c:b9:e4:36:75:33:30:fd:
  35. b3:66:7d:ff:06:01:df:bf:e6:62:a6:d8:d0:e1:ba:d5:0f:4f:
  36. eb:df:99:27:2f:5d:63:1b:0d:15:b3:69:90:63:20:ed:ce:4b:
  37. b4:ad:db:e8:3c:67:5f:ed:39:44:e2:4c:c3:a3:c2:92:b9:f6:
  38. 8c:a5
  39. -----BEGIN CERTIFICATE-----
  40. MIICEzCCAXygAwIBAgIJAIYihA26CdTKMA0GCSqGSIb3DQEBBQUAMEAxCzAJBgNV
  41. BAYTAlBMMRMwEQYDVQQIEwpTb21lLVN0YXRlMRwwGgYDVQQKExNNaW5pIFdlYnNl
  42. cnZpY2UgTHRkMB4XDTA4MDkxNjAzMjEyMloXDTA5MDkxNjAzMjEyMlowQDELMAkG
  43. A1UEBhMCUEwxEzARBgNVBAgTClNvbWUtU3RhdGUxHDAaBgNVBAoTE01pbmkgV2Vi
  44. c2VydmljZSBMdGQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAN5+Cmlpxwbx
  45. Sz0Di0Xcq2M59kQwm3yowP8cuU8psR1ruj0WfLG/6GfWk6TxaLksROeRVAzLsv+v
  46. gMODqoSEp/m52B0askJyLS/+cQxKAgw1NBLVKrze4aNPPHucEjJWca6vvHa25FX0
  47. L9//68dDh7BAgYAeHdN3yWZQzjLy+fqhAgMBAAGjFTATMBEGCWCGSAGG+EIBAQQE
  48. AwIGQDANBgkqhkiG9w0BAQUFAAOBgQA4nl4BlQx8XErNV+Vi7lCQemmeSm909a17
  49. emO2rZQawf8j+Y0BFmxixy29u1Ss1UOh/mCPg2ogegVXb1QOpbw6nLnkNnUzMP2z
  50. Zn3/BgHfv+ZiptjQ4brVD0/r35knL11jGw0Vs2mQYyDtzku0rdvoPGdf7TlE4kzD
  51. o8KSufaMpQ==
  52. -----END CERTIFICATE-----
  53.  
  54. #!/bin/bash
  55.  
  56. # FIXME we need shttp.pem are on same folder like execution path of script
  57. # Extract a certificate sign request form certification file (PEM)
  58. openssl x509 -x509toreq -in shttpd.pem -out shttpd.csr -signkey shttpd.pem
  59. # Extract private key from certification file (PEM)
  60. openssl rsa -in shttpd.pem -out shttpd.key
  61. # Create new certification for ten years
  62. openssl x509 -req -days 3650 -in shttpd.csr -out shttpd.crt.new -signkey shttpd.key
  63. #Concatenate new certificate and old private key on a renewed pem file
  64. cat shttpd.crt.new shttpd.key > shttpd.pem.new
  65.  
  66. openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout example.key -out example.crt -subj "/CN=example.com" -days 3650
  67.  
  68. #!/bin/sh
  69. : '
  70. Script used to renew self-signed certificate saved as PEM
  71. 1st arg - current PEM file
  72. rest args - options for openssl x509 -req
  73.  
  74. new PEM is saved in same directory as old one with .new appendix
  75.  
  76. example usage: ./pemrenew.sh /tmp/keycert.pem -days 365
  77. '
  78.  
  79. # First arg is pointed to current PEM file
  80. pem_file="$1"
  81. shift
  82.  
  83. # Create temporary files
  84. tmp_csr=$(mktemp /tmp/csr.XXXXXXXXX)
  85. tmp_key=$(mktemp /tmp/key.XXXXXXXXX)
  86. tmp_crt=$(mktemp /tmp/crt.XXXXXXXXX)
  87.  
  88. # Extract a certificate sign request form certification file (PEM)
  89. openssl x509 -x509toreq -in $pem_file -out $tmp_csr -signkey $pem_file
  90. # Extract private key from certification file (PEM)
  91. openssl rsa -in $pem_file -out $tmp_key
  92. # Create new certificate with provided options as arguments
  93. openssl x509 -req $@ -in $tmp_csr -out $tmp_crt -signkey $tmp_key
  94.  
  95. # Merge certificate and key to one file
  96. cat $tmp_crt $tmp_key > $pem_file.new
  97.  
  98. # Clean temporary files
  99. rm $tmp_csr $tmp_key $tmp_crt
Add Comment
Please, Sign In to add comment