+
+ // Check for CRL.
+ const DOMElement* crlnode=XMLHelper::getFirstChildElement(root,CRL);
+ if (crlnode) {
+ // Get raw format attrib value, but defer processing til later since may need to
+ // determine format dynamically, and we need the Path for that.
+ format_xml=crlnode->getAttributeNS(NULL,format);
+
+ e=XMLHelper::getFirstChildElement(crlnode,Path);
+ if (e && e->hasChildNodes()) {
+ const XMLCh* s=e->getFirstChild()->getNodeValue();
+ auto_ptr_char kpath(s);
+#ifdef WIN32
+ struct _stat stat_buf;
+ if (_stat(kpath.get(), &stat_buf) != 0)
+#else
+ struct stat stat_buf;
+ if (stat(kpath.get(), &stat_buf) != 0)
+#endif
+ {
+ log.error("CRL file (%s) can't be opened", kpath.get());
+ throw XMLSecurityException("FilesystemCredentialResolver can't access CRL file ($1)",params(1,kpath.get()));
+ }
+ m_crlpath=kpath.get();
+ }
+ else {
+ log.error("Path element missing inside CRL element");
+ throw XMLSecurityException("FilesystemCredentialResolver can't access CRL file, no Path element specified.");
+ }
+
+ // Determine the CRL encoding format dynamically, if not explicitly specified
+ if (format_xml && *format_xml) {
+ fformat = xmlFormatToFormat(format_xml);
+ if (fformat != UNKNOWN) {
+ m_crlformat = fformat;
+ }
+ else {
+ auto_ptr_char unknown(format_xml);
+ log.error("configuration specifies unknown CRL encoding format (%s)", unknown.get());
+ throw XMLSecurityException("FilesystemCredentialResolver configuration contains unknown CRL encoding format ($1)",params(1,unknown.get()));
+ }
+ }
+ else {
+ in=BIO_new(BIO_s_file_internal());
+ if (in && BIO_read_filename(in,m_crlpath.c_str())>0) {
+ m_crlformat = getEncodingFormat(in);
+ log.debug("CRL encoding format for (%s) dynamically resolved as (%s)", m_crlpath.c_str(), formatToString(m_crlformat).c_str());
+ }
+ else {
+ log.error("CRL file (%s) can't be read to determine encoding format", m_crlpath.c_str());
+ throw XMLSecurityException("FilesystemCredentialResolver can't read CRL file ($1) to determine encoding format",params(1,m_crlpath.c_str()));
+ }
+ if (in)
+ BIO_free(in);
+ in = NULL;
+ }