Guest User

asn1_time_to_time_t test

a guest
Sep 18th, 2013
130
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?
  2. $certificate = <<< EOT
  3. -----BEGIN CERTIFICATE-----
  4. MIIF5zCCA8+gAwIBAgIJAJkFoD8fROqHMA0GCSqGSIb3DQEBBQUAMIGIMQswCQYD
  5. VQQGEwJIVTERMA8GA1UECAwIQnVkYXBlc3QxEDAOBgNVBAoMB0JhbGFiaXQxCzAJ
  6. BgNVBAsMAlNEMSYwJAYDVQQDDB1TQ0IgdGVzdCBjZXJ0aWZpY2F0ZSA4OCB5ZWFy
  7. czEfMB0GCSqGSIb3DQEJARYQYmxpbnRAYmFsYWJpdC5odTAgFw0xMzA5MTgwNzA0
  8. MDVaGA8yMTAxMDgyODA3MDQwNVowgYgxCzAJBgNVBAYTAkhVMREwDwYDVQQIDAhC
  9. dWRhcGVzdDEQMA4GA1UECgwHQmFsYWJpdDELMAkGA1UECwwCU0QxJjAkBgNVBAMM
  10. HVNDQiB0ZXN0IGNlcnRpZmljYXRlIDg4IHllYXJzMR8wHQYJKoZIhvcNAQkBFhBi
  11. bGludEBiYWxhYml0Lmh1MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA
  12. wGlG1eV3bqu0gGb5REkOvytB6X8KbCaIq8Xq7RJbnAj6PJmakPPmIlYyZ9MkiS0e
  13. BN6heB/6ZBJlJuxPHd3JRAQyFOnvKR/hRIZNlAfmlh9efdMC4Xmk1f4sDpuaL7aN
  14. /526e7TyEeBibtAPmidnSfWSv63NWYzNY6zXiNHc9cwaYdwHVDu1aREcsMBVv0AC
  15. EVJQGzT6b/l0U85JUYEf2Aitw87Gj/TZJYBJClq9bNFb/ULYAszrfqIzGjK+xKGE
  16. hVf5yodaaQI2kN3vmy0qSHuKeC7SnUwYfjjrUuCL0yJecDfoLpr/LFKTX/WNVmAW
  17. DvK1F5WTzeozG7LfLd91prtje7BJ6TUtl1CloDSH46CZazVTXvzYXIvOG5S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xGeorFgrlUwRaeY3qY
  34. dq7n61/dRzBwfGazs/db6VnSy9/1wBDPmSHK6HWXEDYXpISYpOHpVPqGa1F5NyCN
  35. xhZ7IWhTHn+NsHX4TszZIqsKkCImX4ONttIj
  36. -----END CERTIFICATE-----
  37. EOT;
  38.  
  39. $cert = openssl_x509_read($certificate);
  40. $content = openssl_x509_parse($cert, false);
  41. openssl_x509_free($cert);
  42.  
  43. $valid_to = $content["validTo"];
  44. $valid_to_time_t = $content["validTo_time_t"];
  45. print("Actual time string of validity:  " . $valid_to . "\n");
  46. print("parsed with strtotime:           " . strtotime($valid_to) . " [".date("Y-m-d", strtotime($valid_to)) . "]" . "\n");
  47. print("parsed with asn1_time_to_time_t: " . $valid_to_time_t . "  [".date("Y-m-d", $valid_to_time_t) . "]" . "\n");
  48. ?>
RAW Paste Data