@@ -113,75 +113,34 @@ Additionally it makes sure that all IGTF CAs are installed.
113113 certdir = rsvprobe .get_ca_dir ()
114114 self .verify_CRL (certdir , self .warningHrs , self .errorHrs )
115115
116- def get_osg_CAs (self , ca_format_type , grid_type ):
117- "Download and parce the CA list from OSG GOC"
118- if not grid_type in [0 , 1 ]:
119- self .return_unknown ("ERROR: Unknown grid type %s. Setting metric to unknown." % grid_type )
120- if not ca_format_type in [0 , 1 ]:
121- self .return_unknown ("ERROR: CA Certs Directory has unknown certificate type %s. Setting metric to unknown." %
122- ca_format_type )
116+ def get_osg_CAs (self ):
117+ "Download and parse the CA list from OSG repo"
123118 source_name = {} # list of crl files name -> data (hash0, hash1, accreditation)
124119 source_hash0 = {} # Old hash -> accreditation
125120 source_hash1 = {} # New hash -> accreditation
126- local_urls = [["http://repo.opensciencegrid.org/pacman/cadist/INDEX.txt" ]
127- ["http://repo.opensciencegrid.org/pacman/cadist/INDEX-new.txt" ]
128- ]
129- local_url = local_urls [ca_format_type ][grid_type ]
130- # Download the CA list file from OSG/ITB cache
131- lines = rsvprobe .get_http_doc (local_url )
121+ # Download the CA list file
122+ lines = rsvprobe .get_http_doc (rsvprobe .CA_CERT_INDEX_URL )
132123 if not lines :
133- self .return_unknown ("Could not download the CA list from OSG (%s) or the file is empty. Unable to verify CRLs." % local_url )
124+ self .return_unknown ("Could not download the CA list from OSG (%s) or the file is empty."
125+ " Unable to verify CRLs." % rsvprobe .CA_CERT_INDEX_URL )
134126 ## Parsing of the CA list
135- ## type 1 format:
136- ## OldHash NewHash CAfile CAURL Version Accreditation
127+ ## OldHash NewHash CAfile CAURL Version Accreditation
137128 ##--------------------------------------------------------------------------------------------------------
138129 #75680d2e ee64a828 AAACertificateServices.pem https://www.terena.org/activities/tcs/ 1.41 I
139130 #3c58f906 157753a5 AddTrust-External-CA-Root.pem http://www.comodo.com/ 1.41 I
140- ## type 0 format:
141- ## Hash Source URL Accreditation
142- ##--------------------------------------------------------------------------------------------------------
143- #09ff08b7 CNRS2-Projets http://igc.services.cnrs.fr/GRID-FR/ I
144- #0a12b607 UGRID https://ca.ugrid.org/ I
145131 for line in lines :
146132 if not line or line .startswith ('#' ):
147133 continue
148134 line_content = line .split ()
149- if ca_format_type == 1 :
150- # New CA format type, both old hash (hash0) and new hash (hash1), source name has extension (filename)
151- source_hash0 [line_content [0 ]] = line_content [- 1 ]
152- source_hash1 [line_content [1 ]] = line_content [- 1 ]
153- source_name [line_content [2 ].split ('.' )[0 ]] = { 'hash' : line_content [0 ],
154- 'newhash' : line_content [1 ],
155- 'accreditation' : line_content [- 1 ]
156- }
157- else : # assuming type 0
158- # Assuming CA format type (type 0), only old hash (hash0), source name has no extension
159- source_hash0 [line_content [0 ]] = line_content [- 1 ]
160- source_name [line_content [1 ]] = { 'hash' : line_content [0 ],
161- 'newhash' : None ,
162- 'accreditation' : line_content [- 1 ]
163- }
164- return source_name , source_hash0 , source_hash1
135+ # New CA format type, both old hash (hash0) and new hash (hash1), source name has extension (filename)
136+ source_hash0 [line_content [0 ]] = line_content [- 1 ]
137+ source_hash1 [line_content [1 ]] = line_content [- 1 ]
138+ source_name [line_content [2 ].split ('.' )[0 ]] = { 'hash' : line_content [0 ],
139+ 'newhash' : line_content [1 ],
140+ 'accreditation' : line_content [- 1 ]
141+ }
142+ return source_name , source_hash0 , source_hash1
165143
166- def parse_ca_index (self , certdir ):
167- "Parse INDEX.txt in CA certs directory and retrieve IndexTypeVersion, default to 0"
168- ca_format_type = 0
169- ca_index = os .path .join (certdir , "INDEX.txt" )
170- if os .path .isfile (ca_index ):
171- try :
172- lines = open (ca_index ).readlines ()
173- for i in lines :
174- if i .find ("IndexTypeVersion" ) >= 0 :
175- try :
176- ca_format_type = int (i .split ()[2 ])
177- except IndexError :
178- # When missing it is 0 (default value)
179- pass
180- except (OSError , ValueError ):
181- # If I don't find the index file or don't find the keyword IndexTypeVersion assume type 0
182- pass
183- return ca_format_type
184-
185144 def verify_CRL (self , certdir , warnHrs , errHrs ):
186145 """Check_Freshness_Local_CRL: Checks the last time when the CRLs were successfully downloaded
187146parameters :
@@ -192,15 +151,9 @@ errHrs: Number hours since the failing downloads before an error is issued
192151"""
193152 #status_code = 0 # Return status code as expected by RSV for summaryData
194153 found_crls = []
195- ca_format_type = 0
196154
197155 # Step 1: Get the list of Certs included in OSG from GOC website.
198- ca_format_type = self .parse_ca_index (certdir )
199-
200- #Check if the file CA certs are installed from ITB
201- # grid_type: 0 - osg; 1 - itb
202- grid_type = rsvprobe .get_grid_type ()
203- source_name , source_hash0 , source_hash1 = self .get_osg_CAs (ca_format_type , grid_type )
156+ source_name , source_hash0 , source_hash1 = self .get_osg_CAs ()
204157
205158 # Step 2: Get and Check time stamps on the CRL files to ensure that it has been recently downloaded
206159 error_count = 0
@@ -211,8 +164,7 @@ errHrs: Number hours since the failing downloads before an error is issued
211164 self .return_unknown ("ERROR: CA Certs Directory %s contains no CRL files (*.r0). Aborting the probe (UNKOWN status)." %
212165 certdir )
213166 source_hash_list = source_hash0 .keys ()
214- if ca_format_type == 1 :
215- source_hash_list += source_hash1 .keys ()
167+ source_hash_list += source_hash1 .keys ()
216168 for i in crl_files :
217169 local_hash = os .path .basename (i ).split ('.' )[0 ] #remove the extension
218170 # List of CRLs found.
@@ -232,13 +184,12 @@ errHrs: Number hours since the failing downloads before an error is issued
232184 pass # not in hash0
233185 # keep the following outside form the except to cover the case when the hash h1 is the old hash of CA cert c1
234186 # and new hash of CA cert c2. Is this possible?
235- if not is_igtf_cert and ca_format_type == 1 :
187+ if not is_igtf_cert :
236188 try :
237189 if source_hash1 [local_hash ].find ('I' ) >= 0 :
238190 is_igtf_cert = True
239191 except KeyError :
240192 pass # not in hash1
241- if not is_igtf_cert :
242193 if self .verbose :
243194 self .add_ok ("EGEE test and CRL file for CA with hash %s that is not in IGTF, ignored." % local_hash )
244195 continue
@@ -265,25 +216,23 @@ errHrs: Number hours since the failing downloads before an error is issued
265216 # Ignore non IGTF CAs for wlcg probe
266217 continue
267218 # continue if found CRL
268- if ca_format_type == 1 and ca_info ['newhash' ] in found_crls :
219+ if ca_info ['newhash' ] in found_crls :
269220 continue
270221 if ca_info ['hash' ] in found_crls :
271222 continue
272- # continue if the CA file has been removed
273- # if ca_format_type == 1 then both CA files must have been removed to continue
223+ # continue if the both CA files have been removed
274224 if not os .path .isfile (os .path .join (certdir , "%s.0" % ca_info ['hash' ])):
275- if ca_format_type != 1 or not os .path .isfile (os .path .join (certdir , "%s.0" % ca_info ['newhash' ])):
225+ if not os .path .isfile (os .path .join (certdir , "%s.0" % ca_info ['newhash' ])):
276226 continue
277- warning = ("MISSING: CRL file for %s (%s/%s, type %s ) is missing. OSG policy requires CRL for every CA distributed by OSG." %
278- (name , ca_info ['newhash' ], ca_info ['hash' ], ca_format_type ))
227+ warning = ("MISSING: CRL file for %s (%s/%s) is missing. OSG policy requires CRL for every CA distributed by OSG." %
228+ (name , ca_info ['newhash' ], ca_info ['hash' ]))
279229 if missing_count == 0 :
280230 warning += (
281231 "\n - Has fetch-crl run recently? (See /etc/cron.d/fetch-crl*)\n "
282232 "- See fetch-crl output (mailed to root by cron or sent to syslog), "
283233 "or try running fetch-crl by hand to inspect its output.\n "
284234 "- More info on troubleshooting this probe can be found at: "
285- "https://www.opensciencegrid.org/bin/view/Documentation/Release3/RsvProbeCrlFreshnessProbe\n "
286- "- For more help, submit a ticket to the GOC at: https://ticket.opensciencegrid.org/" )
235+ "- For more help, send email to help@opensciencegrid.org" )
287236 self .add_warning (warning )
288237 missing_count += 1
289238
0 commit comments