Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1910)

Side by Side Diff: net/third_party/mozilla_security_manager/nsPKCS12Blob.cpp

Issue 7338011: Linux Cert manager: improve PKCS #12 import error messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/net_error_list.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* ***** BEGIN LICENSE BLOCK ***** 1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 * 3 *
4 * The contents of this file are subject to the Mozilla Public License Version 4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with 5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at 6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/ 7 * http://www.mozilla.org/MPL/
8 * 8 *
9 * Software distributed under the License is distributed on an "AS IS" basis, 9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 CERT_DestroyCertList(cert_list); 221 CERT_DestroyCertList(cert_list);
222 if (srv) goto finish; 222 if (srv) goto finish;
223 } 223 }
224 224
225 import_result = net::OK; 225 import_result = net::OK;
226 finish: 226 finish:
227 // If srv != SECSuccess, NSS probably set a specific error code. 227 // If srv != SECSuccess, NSS probably set a specific error code.
228 // We should use that error code instead of inventing a new one 228 // We should use that error code instead of inventing a new one
229 // for every error possible. 229 // for every error possible.
230 if (srv != SECSuccess) { 230 if (srv != SECSuccess) {
231 if (SEC_ERROR_BAD_PASSWORD == PORT_GetError()) { 231 int error = PORT_GetError();
232 import_result = net::ERR_PKCS12_IMPORT_BAD_PASSWORD; 232 LOG(ERROR) << "PKCS#12 import failed with error " << error;
233 } 233 switch (error) {
234 else 234 case SEC_ERROR_BAD_PASSWORD:
235 { 235 case SEC_ERROR_PKCS12_PRIVACY_PASSWORD_INCORRECT:
236 LOG(ERROR) << "PKCS#12 import failed with error " << PORT_GetError(); 236 import_result = net::ERR_PKCS12_IMPORT_BAD_PASSWORD;
237 import_result = net::ERR_PKCS12_IMPORT_FAILED; 237 break;
238 case SEC_ERROR_PKCS12_INVALID_MAC:
239 import_result = net::ERR_PKCS12_IMPORT_INVALID_MAC;
240 break;
241 case SEC_ERROR_BAD_DER:
242 case SEC_ERROR_PKCS12_DECODING_PFX:
243 case SEC_ERROR_PKCS12_CORRUPT_PFX_STRUCTURE:
244 import_result = net::ERR_PKCS12_IMPORT_INVALID_FILE;
245 break;
246 case SEC_ERROR_PKCS12_UNSUPPORTED_MAC_ALGORITHM:
247 case SEC_ERROR_PKCS12_UNSUPPORTED_TRANSPORT_MODE:
248 case SEC_ERROR_PKCS12_UNSUPPORTED_PBE_ALGORITHM:
249 case SEC_ERROR_PKCS12_UNSUPPORTED_VERSION:
250 import_result = net::ERR_PKCS12_IMPORT_UNSUPPORTED;
251 break;
252 default:
253 import_result = net::ERR_PKCS12_IMPORT_FAILED;
254 break;
238 } 255 }
239 } 256 }
240 // Finish the decoder 257 // Finish the decoder
241 if (dcx) 258 if (dcx)
242 SEC_PKCS12DecoderFinish(dcx); 259 SEC_PKCS12DecoderFinish(dcx);
243 SECITEM_ZfreeItem(&unicodePw, PR_FALSE); 260 SECITEM_ZfreeItem(&unicodePw, PR_FALSE);
244 return import_result; 261 return import_result;
245 } 262 }
246 263
247 264
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 finish: 439 finish:
423 if (srv) 440 if (srv)
424 LOG(ERROR) << "PKCS#12 export failed with error " << PORT_GetError(); 441 LOG(ERROR) << "PKCS#12 export failed with error " << PORT_GetError();
425 if (ecx) 442 if (ecx)
426 SEC_PKCS12DestroyExportContext(ecx); 443 SEC_PKCS12DestroyExportContext(ecx);
427 SECITEM_ZfreeItem(&unicodePw, PR_FALSE); 444 SECITEM_ZfreeItem(&unicodePw, PR_FALSE);
428 return return_count; 445 return return_count;
429 } 446 }
430 447
431 } // namespace mozilla_security_manager 448 } // namespace mozilla_security_manager
OLDNEW
« no previous file with comments | « net/base/net_error_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698