Guest User

Untitled

a guest
Dec 9th, 2015
131
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use strict;
  2. use warnings;
  3. use IO::Socket::SSL::Utils 1.973;
  4.  
  5. # create root.pem and server.pem
  6. # $ca defines the constraints on the root certificate
  7. #   my $ca = undef; # no constraints
  8. #   my $ca = 1;     # CA:true
  9. #   my $ca = 0;     # CA:false
  10.  
  11. my $ca = undef; # no constraints
  12.  
  13. my $c0 = PEM_string2cert(<<'CERT');
  14. -----BEGIN CERTIFICATE-----
  15. MIICATCCAWoCCQDzZYnslbBnujANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJB
  16. VTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0
  17. cyBQdHkgTHRkMB4XDTE1MTIwOTEyMjIyMVoXDTE2MTIwODEyMjIyMVowRTELMAkG
  18. A1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0
  19. IFdpZGdpdHMgUHR5IEx0ZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAp5O+
  20. KsRA/K568wx1qU5/H8v89U4TrHNrQMw6bfM7uzxzILsQdJ54F2pY4+g8RPE30Btr
  21. xo01sWSvzEh3FMN7dr9mvhgkrZjazE6K1GRmpSiuaVwU02RqgFXelEyEemK5SbqL
  22. hLuiBQKO53jLIL5TbXoIIuYe3/XTkcZCTsqS4csCAwEAATANBgkqhkiG9w0BAQsF
  23. AAOBgQBDxn3zcZEMl8fN7MD3B4ljEPp2qkPi04fjemO6GOjdas2OTyvBAZ5KB0cW
  24. nsflxr4RYyBir5eSFk57Apom2LHQaQiesQ6CwcwmcBEM70dbNrHSctYRBO9QsgVj
  25. tJ5gTWfCWyNeufLUJTj4vOk40lWRyJrVULaGoe1DA5FRT0CotQ==
  26. -----END CERTIFICATE-----
  27. CERT
  28.  
  29. my $k0 = PEM_string2key(<<'KEY');
  30. -----BEGIN RSA PRIVATE KEY-----
  31. MIICWwIBAAKBgQCnk74qxED8rnrzDHWpTn8fy/z1ThOsc2tAzDpt8zu7PHMguxB0
  32. nngXaljj6DxE8TfQG2vGjTWxZK/MSHcUw3t2v2a+GCStmNrMTorUZGalKK5pXBTT
  33. ZGqAVd6UTIR6YrlJuouEu6IFAo7neMsgvlNteggi5h7f9dORxkJOypLhywIDAQAB
  34. AoGASPQN3upvbFG9XuA2vQ1aVIpmxphGAlaBA8WlTkaM43dum3o0sMBogbEfn6Bz
  35. 1IO7C5NUeSzyihbOXb3Scaykq5pA6MEURYKfiyUs/BcEUE2H+xkeBuK5Tb1b4sgQ
  36. BybhMPV0GRarIYNTP3B/pR+GbTLA3ahGMN/bA1JLr7+BncECQQDU8VfGtPJ71W6B
  37. vkfg2/XOC/ViCeUIZZexXzna4y17KLOwS7v22GsoG5U0F80yIUkXCox6EesvTTsh
  38. J/VE64shAkEAyXYeD6OyCvxAkcjQWO+Nm+9xLSZqGF0EN/wr1MeznadTCP4ShHOI
  39. g5Q3pg2xm10fs4mzl08w9sNTBGbgn0tbawJABEXPcBJDZ06yB/JseMuRFBBTXSM7
  40. sD5xm8KAY675Q6ZebKQoYlyXUdez17a+jEn0sHyqsuxXHrza+eBWYIqlYQJAET7F
  41. L/2JPht9w3z3KMXIz3Jds8m4B0HfHJO/hMVbgMFUAE8PcrsZEnpbkSFW9L+x+QJu
  42. lyM2Q8lQj+3miHxA5QJAJHrMQrfWxf9hBadL/zVHn2LdeimLFdrTvE+DzCmI/0UP
  43. mYYZQI4kpvc7VaVvR984Nzdvoe+tVGkZ6ufLPU7/hQ==
  44. -----END RSA PRIVATE KEY-----
  45. KEY
  46.  
  47. ($c0,$k0) = CERT_create( CA => $ca, subject => { CN => 'root' })
  48.     if defined $ca;
  49. my ($c1,$k1) = CERT_create( issuer => [ $c0,$k0 ], subject => { CN => 'server' });
  50.  
  51. PEM_cert2file($c0,'root.pem');
  52. open(my $fh,'>','server.pem');
  53. print $fh PEM_cert2string($c1).PEM_key2string($k1);
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×