Skip to content

Commit 1f76ade

Browse files
committed
refactor (dirac-login): use source error message
1 parent ec840b1 commit 1f76ade

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/DIRAC/FrameworkSystem/scripts/dirac_login.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,12 @@ def loginWithCertificate(self):
267267
chain = X509Chain()
268268
# Load user cert and key
269269
result = chain.loadChainFromFile(self.certLoc)
270+
if result["OK"]:
271+
result = chain.loadKeyFromFile(self.keyLoc, password=getpass.getpass("Enter Certificate password:"))
270272
if not result["OK"]:
271-
return S_ERROR(f"Can't load {self.certLoc}: {result['Message']}")
272-
result = chain.loadKeyFromFile(self.keyLoc, password=getpass.getpass("Enter Certificate password:"))
273-
if not result["OK"]:
274-
if "bad decrypt" in result["Message"] or "bad pass phrase" in result["Message"]:
275-
return S_ERROR("Bad passphrase")
276-
return S_ERROR(f"Can't load {self.keyLoc}: {result['Message']}")
273+
return result
277274

278-
# Remember a clean proxy to then upload it
275+
# Remember a clean proxy to then upload it in step 2
279276
proxy = copy.copy(chain)
280277

281278
# Create local proxy with group
@@ -288,7 +285,7 @@ def loginWithCertificate(self):
288285
return S_ERROR("Cannot contact CS.")
289286
gConfig.forceRefresh()
290287

291-
# Upload proxy to DIRAC server
288+
# Step 2: Upload proxy to DIRAC server
292289
return gProxyManager.uploadProxy(proxy)
293290

294291
def howToSwitch(self) -> bool:

0 commit comments

Comments
 (0)