Commits

Konstantin Baierer  committed cd88ce9

Made expiration checks more verbose and one usable test

  • Participants
  • Parent commits 8054327

Comments (0)

Files changed (2)

File examples/testing.pl

 DLmcf0RI0RtEUaXDLwTf7jtnlDWs41so0Bu8FEAuDvCTvTdOTBGqEhAvVA==
 -----END CERTIFICATE-----';
 
-my $auth = CGI::Auth::FOAF_SSL->new($cert);
+my $foaf_ssl_webid = '-----BEGIN CERTIFICATE-----
+MIIDWzCCAsSgAwIBAgIJAPWKstF2BhSOMA0GCSqGSIb3DQEBBQUAMG0xCzAJBgNV
+BAYTAkZSMRAwDgYDVQQIEwdFc3Nvbm5lMRYwFAYDVQQKEw13ZWJpZC5mY25zLmV1
+MRYwFAYDVQQDEw13ZWJpZC5mY25zLmV1MRwwGgYJKoZIhvcNAQkBFg13ZWJpZEBm
+Y25zLmV1MB4XDTEyMDMyNjE3MDE0OFoXDTEzMDMyNjE3MDE0OFowKjEoMCYGA1UE
+AxQfQ0dJOjpBdXRoOjpGT0FGX19TU0wgdGVzdCBXZWJJRDCCASIwDQYJKoZIhvcN
+AQEBBQADggEPADCCAQoCggEBANGm37aQgbqPbUqTAYGHyexDPEK4U3lGbI0ItBsg
+QMDp2E/BRnbr+yKN8IMQy/LUExXTLJaiUBYJKgT2UI/cy8HZ/U4mgDDbptC5Nfe2
+De9WEZ57+glWwZqdrlsxU80TpUnzXgtrJ+xNvgWMRNO+fW2bLA3dyP9SQ6sC1bEE
+NVHyfYjb/mURfQPmlh2hg9xdLNXx4gMXM/wQ3FGJpz4SaS9wyTYnBqOHS/f5pfCl
+3qa2WYy1BmGgundcGBI7d3IS7Bbuh0zo6/FVzeZdiDmnCbYGto26HolXjSsZWcVj
+XkEQiq46UAnss61O0Rp8eFTiN5MP9NlddLRrSoeJ4fXPTBUCAwEAAaOBwTCBvjAJ
+BgNVHRMEAjAAMCwGCWCGSAGG+EIBDQQfFh1PcGVuU1NMIEdlbmVyYXRlZCBDZXJ0
+aWZpY2F0ZTAdBgNVHQ4EFgQU5bFe6DBFF8cohPvZ5ZOnMwiDfsAwHwYDVR0jBBgw
+FoAUK9/vv3kTc8vk1DWlC+wYLGPk0vAwQwYDVR0RBDwwOoY4aHR0cDovL3dlYmlk
+LmZjbnMuZXUvcGVvcGxlL3A1LWNnaS1hdXRoLWZvYWYtc3NsL2NhcmQjbWUwDQYJ
+KoZIhvcNAQEFBQADgYEAVjpH54A2iTWNR24bNGrCfegsrPzuSvPXAk/GIAz3fK53
+WJpJKNlEMTiXEGXfX0CFIJMNtwNXodSAxwU9xTSs6fSIe6m1cb5o8dnMAZ8bW3ss
+HTRS2zGtz4CPPbA9Y4YYg/aP9NeLGw4dLcP+j5FhpkCkLMUVqDxKyBmcjkQVPz8=
+-----END CERTIFICATE-----';
+
+my $auth = CGI::Auth::FOAF_SSL->new($foaf_ssl_webid);
 p $auth;
 
 #print $auth->account->identity . "\n";

File lib/CGI/Auth/FOAF_SSL.pm

 use RDF::TrineShortcuts 0.100;
 use Scalar::Util 0 qw[blessed];
 
+# use Data::Printer 0;
+
 use constant {
 	VALIDATION_PEM     => 1,
 	VALIDATION_DATES   => 2,
 	return unless $self->validation(VALIDATION_PEM);
 	
 	my $now = DateTime->now;
-	return if defined $self->cert_not_before && $now < $self->cert_not_before;
-	return if defined $self->cert_not_after  && $now > $self->cert_not_after;
+	if (defined $self->cert_not_before && $now < $self->cert_not_before) {
+        warn "Certificate isn't valid yet! Try again on " . $self->cert_not_before->iso8601;
+        return
+    }
+	if (defined $self->cert_not_after  && $now > $self->cert_not_after) {
+        warn "Certificate has expired on " . $self->cert_not_after->iso8601;
+        return;
+    }
 
 	$self->validation(VALIDATION_DATES);