Closed
Bug 917175
Opened 11 years ago
Closed 10 years ago
[Wifi] Support delete imported CA in NSS
Categories
(Firefox OS Graveyard :: Wifi, defect)
Tracking
(feature-b2g:2.0, tracking-b2g:backlog)
People
(Reporter: chucklee, Assigned: chucklee)
References
Details
Attachments
(3 files, 18 obsolete files)
(deleted),
patch
|
mrbkap
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review |
The API should look like
nsIDOMDOMRequest deleteCa(in DOMString certNickname);
Should only delete CAs imported by wifi manager, so we need to find a identifying method in Bug 917102.
Updated•11 years ago
|
blocking-b2g: --- → 1.3+
Updated•11 years ago
|
Target Milestone: --- → 1.3 Sprint 4 - 11/8
Updated•11 years ago
|
Whiteboard: [FT:RIL]
Updated•11 years ago
|
Target Milestone: 1.3 Sprint 4 - 11/8 → 1.3 Sprint 5 - 11/22
Updated•11 years ago
|
Target Milestone: 1.3 Sprint 5 - 11/22 → 1.3 Sprint 6 - 12/6
Assignee | ||
Updated•11 years ago
|
Assignee | ||
Comment 1•11 years ago
|
||
Attachment #8336565 -
Flags: review?(vchang)
Attachment #8336565 -
Flags: review?(mrbkap)
Assignee | ||
Comment 2•11 years ago
|
||
Attachment #8336566 -
Flags: review?(vchang)
Attachment #8336566 -
Flags: review?(mrbkap)
Attachment #8336566 -
Flags: review?(brian)
Assignee | ||
Comment 3•11 years ago
|
||
Attachment #8336567 -
Flags: review?(vchang)
Attachment #8336567 -
Flags: review?(mrbkap)
Comment 4•11 years ago
|
||
I'm going to review this tomorrow (California time).
Assignee | ||
Comment 5•11 years ago
|
||
Update to fit change in bug 917102.
Attachment #8336566 -
Attachment is obsolete: true
Attachment #8336566 -
Flags: review?(vchang)
Attachment #8336566 -
Flags: review?(mrbkap)
Attachment #8336566 -
Flags: review?(brian)
Attachment #8338292 -
Flags: review?(vchang)
Attachment #8338292 -
Flags: review?(mrbkap)
Attachment #8338292 -
Flags: review?(brian)
Comment 6•11 years ago
|
||
Comment on attachment 8336565 [details] [diff] [review]
0001. IDL Change.
Review of attachment 8336565 [details] [diff] [review]:
-----------------------------------------------------------------
One non-nit question here.
::: dom/wifi/nsIWifi.idl
@@ +196,5 @@
> + * Nickname of imported to be deleted.
> + * onsuccess: We have successfully deleted certificate.
> + * onerror: We have failed to delete certificate.
> + */
> + nsIDOMDOMRequest deleteCa(in DOMString certNickname);
This might be a silly question: but I think bsmith told me that nicknames are not necessarily unique. Should we be passing in the cert's fingerprint instead?
Attachment #8336565 -
Flags: review?(mrbkap)
Comment 7•11 years ago
|
||
Comment on attachment 8336567 [details] [diff] [review]
0003. DOM API implementation.
Review of attachment 8336567 [details] [diff] [review]:
-----------------------------------------------------------------
Clearing this request until my question about the API is answered.
Attachment #8336567 -
Flags: review?(mrbkap)
Comment 8•11 years ago
|
||
Comment on attachment 8338292 [details] [diff] [review]
0002. Backend. V2
Review of attachment 8338292 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/wifi/NssUtils.cpp
@@ +296,5 @@
> + if (!cert) {
> + continue;
> + }
> +
> + srv = SEC_DeletePermCertificate(cert);
This means that we might delete two certs for one call here. Is that intended?
Attachment #8338292 -
Flags: review?(mrbkap)
Comment 9•11 years ago
|
||
Comment on attachment 8338292 [details] [diff] [review]
0002. Backend. V2
Review of attachment 8338292 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/wifi/NssUtils.cpp
@@ +289,5 @@
> + SECStatus srv;
> +
> + CopyUTF16toUTF8(aNickname, userNickname);
> + for (int i = 0; i < 2; i++) {
> + snprintf(nickname, sizeof(nickname), "%s%s", nicknamePrefix[i], userNickname.get());
You would need to check the return value here, if you continue using snprintf.
However, I suggest that instead you sue the much-safer ns[AC]String methods that do correct bounds checking automatically (crash on memory allocation failure).
@@ +300,5 @@
> + srv = SEC_DeletePermCertificate(cert);
> +
> + if (srv != SECSuccess) {
> + return NS_ERROR_UNEXPECTED;
> + }
Please use MapSECStatus.
::: dom/wifi/WifiCaService.cpp
@@ +115,5 @@
> NS_DispatchToMainThread(runnable);
> }
> };
>
> +class DeleteCaRunnable : public nsRunnable
I suggest replacing this with CryptoTask, which handles NSS shutdown correctly.
You need to check for NSS shutdown. Also, this will do file I/O (NSS certificate database access) on the main thread.
I suggest that you try using the CryptoTask framework to avoid the main-thread I/O and also avoid having to deal with NSS shutdown. You can find some good examples of how to use CryptoTask in the Gecko source code. (e.g. toolkit/identity, IIRC.)
I suggest you try using CryptoTask for the Importing part too.
Attachment #8338292 -
Flags: review?(brian) → review-
Updated•11 years ago
|
Attachment #8336565 -
Flags: review?(vchang)
Updated•11 years ago
|
Attachment #8336567 -
Flags: review?(vchang)
Updated•11 years ago
|
Attachment #8338292 -
Flags: review?(vchang)
Assignee | ||
Comment 10•11 years ago
|
||
(In reply to Blake Kaplan (:mrbkap) from comment #6)
> Comment on attachment 8336565 [details] [diff] [review]
> 0001. IDL Change.
>
> Review of attachment 8336565 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> One non-nit question here.
>
> ::: dom/wifi/nsIWifi.idl
> @@ +196,5 @@
> > + * Nickname of imported to be deleted.
> > + * onsuccess: We have successfully deleted certificate.
> > + * onerror: We have failed to delete certificate.
> > + */
> > + nsIDOMDOMRequest deleteCa(in DOMString certNickname);
>
> This might be a silly question: but I think bsmith told me that nicknames
> are not necessarily unique. Should we be passing in the cert's fingerprint
> instead?
Using nickname instead of hash is because it's easier for user to select from list.
And for wifi usage, we have to ensure the nickname is unique for wpa_supplicant to get.
So there's a check in |importCa()| to prevent redundant nickname.
Because we use nickname directly in Gaia settings and wpa_supplicant config, so we don't have to maintain a database for the mapping.
Assignee | ||
Comment 11•11 years ago
|
||
(In reply to Blake Kaplan (:mrbkap) from comment #8)
> Comment on attachment 8338292 [details] [diff] [review]
> 0002. Backend. V2
>
> Review of attachment 8338292 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: dom/wifi/NssUtils.cpp
> @@ +296,5 @@
> > + if (!cert) {
> > + continue;
> > + }
> > +
> > + srv = SEC_DeletePermCertificate(cert);
>
> This means that we might delete two certs for one call here. Is that
> intended?
Yes, one for server certificate, one for user certificate.
In my assumption, these two certificate should only have same nickname because they are imported at once - by pkcs12 format.
Since pkcs12 is move out of current scope, next patch will only import/delete server patches.
Assignee | ||
Comment 12•11 years ago
|
||
Change API function name.
Attachment #8336565 -
Attachment is obsolete: true
Attachment #8339796 -
Flags: review?(mrbkap)
Assignee | ||
Comment 13•11 years ago
|
||
Address comment 9, including:
1. Use nsCString instead of c type string.
2. Use MapSECStatus() for returning error code.
3. Use CryptoTask instead of Runnable to do I/O outside of main thread.
Attachment #8338292 -
Attachment is obsolete: true
Attachment #8339798 -
Flags: review?(mrbkap)
Attachment #8339798 -
Flags: review?(brian)
Assignee | ||
Comment 14•11 years ago
|
||
1. Changes corresponding to API function name change.
2. Answers for API is in comment 10.
Attachment #8336567 -
Attachment is obsolete: true
Attachment #8339801 -
Flags: review?(mrbkap)
Comment 15•11 years ago
|
||
The user story bug this blocks (bug 922930) has a target milestone of future, so this is not a committed feature for 1.3. Non-committed features for 1.3 should not block the release.
blocking-b2g: 1.3+ → 1.3?
Comment 16•11 years ago
|
||
(In reply to Chuck Lee [:chucklee] from comment #10)
> Using nickname instead of hash is because it's easier for user to select
> from list.
Sure, but the user isn't the one calling the API function ;-). It isn't a ton more work for the Gaia code to keep a mapping, which would let us have the best of both worlds. That being said...
> And for wifi usage, we have to ensure the nickname is unique for
> wpa_supplicant to get.
> So there's a check in |importCa()| to prevent redundant nickname.
I must have missed that. This needs at least a comment somewhere in the IDL.
> Because we use nickname directly in Gaia settings and wpa_supplicant config,
> so we don't have to maintain a database for the mapping.
In general, I'm against implementation details dictating API design -- there hopefully will be other implementations of this API that may not be based on wpa_supplicant and which wouldn't necessarily have this limitation. That being said, having multiple certs with the same nickname seems like Bad News (TM) for the user anyway, so it seems reasonable for me to keep it in the API.
Comment 17•11 years ago
|
||
Comment on attachment 8339796 [details] [diff] [review]
0001. IDL Change. V2
Review of attachment 8339796 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/wifi/nsIWifiCertService.idl
@@ +41,5 @@
> + * @param certNickname
> + * Certificate nickname to delete.
> + */
> + void deleteCert(in long id,
> + in DOMString certNickname);
I think you need to bump the IID here.
Attachment #8339796 -
Flags: review?(mrbkap) → review+
Comment 18•11 years ago
|
||
Comment on attachment 8339798 [details] [diff] [review]
0002. Backend. V3
Review of attachment 8339798 [details] [diff] [review]:
-----------------------------------------------------------------
Nits only from me.
::: dom/wifi/WifiCertService.cpp
@@ +79,5 @@
> + mResult.mStatus = 0;
> + mResult.mUsageFlag = 0;
> + mResult.mNickname = aCertNickname;
> +
> + MOZ_ASSERT(NS_IsMainThread());
Uber-nit: I'd put this assertion at the top of the function.
@@ +91,5 @@
> + MOZ_ASSERT(!NS_IsMainThread());
> + NssUtils nssUtil;
> +
> + nsresult rv = nssUtil.DeleteCert(mResult.mNickname);
> + return rv;
Nit: no need for rv.
Attachment #8339798 -
Flags: review?(mrbkap) → review+
Updated•11 years ago
|
Attachment #8339801 -
Flags: review?(mrbkap) → review+
Assignee | ||
Comment 19•11 years ago
|
||
(In reply to Blake Kaplan (:mrbkap) from comment #17)
> Comment on attachment 8339796 [details] [diff] [review]
> 0001. IDL Change. V2
>
> Review of attachment 8339796 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> ::: dom/wifi/nsIWifiCertService.idl
> @@ +41,5 @@
> > + * @param certNickname
> > + * Certificate nickname to delete.
> > + */
> > + void deleteCert(in long id,
> > + in DOMString certNickname);
>
> I think you need to bump the IID here.
id here is used to find the corresponding callback in WifiManager, it can't be removed.
Assignee | ||
Comment 20•11 years ago
|
||
Address comment 17.
Attachment #8339796 -
Attachment is obsolete: true
Assignee | ||
Comment 21•11 years ago
|
||
Address comment 18.
Attachment #8339798 -
Attachment is obsolete: true
Attachment #8339798 -
Flags: review?(brian)
Assignee | ||
Updated•11 years ago
|
Attachment #8343517 -
Flags: review?(brian)
Updated•11 years ago
|
blocking-b2g: 1.3? → 1.4+
Target Milestone: 1.3 Sprint 6 - 12/6 → ---
Assignee | ||
Comment 24•11 years ago
|
||
Rebase.
Attachment #8343517 -
Attachment is obsolete: true
Attachment #8343517 -
Flags: review?(brian)
Attachment #8371281 -
Flags: review?(brian)
Comment 26•11 years ago
|
||
After discussing PM, it is not an 1.4+ bug. Put it in backlog.
blocking-b2g: 1.4+ → backlog
Comment 27•11 years ago
|
||
Comment on attachment 8371281 [details] [diff] [review]
0002. Backend. V5
Review of attachment 8371281 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/wifi/NssUtils.cpp
@@ +166,5 @@
> + ScopedCERTCertificate cert(
> + CERT_FindCertByNickname(CERT_GetDefaultCertDB(), serverCertName.get())
> + );
> + if (!cert) {
> + return NS_ERROR_UNEXPECTED;
Wouldn't MapSECStatus(SECFailure) be better here?
::: dom/wifi/WifiCertService.cpp
@@ +71,5 @@
>
> +class DeleteCertTask MOZ_FINAL: public CryptoTask
> +{
> +public:
> + DeleteCertTask(int32_t aId, const nsAString & aCertNickname)
NIT: const nsAString& aCertNickname
@@ +89,5 @@
> + {
> + MOZ_ASSERT(!NS_IsMainThread());
> + NssUtils nssUtil;
> +
> + return nssUtil.DeleteCert(mResult.mNickname);
Consider just inlining nssUtil.DeleteCert into here.
@@ +194,5 @@
> return NS_OK;
> }
>
> +NS_IMETHODIMP
> +WifiCertService::DeleteCert(int32_t aId, const nsAString & aCertNickname)
NIT: const nsAString&
@@ +197,5 @@
> +NS_IMETHODIMP
> +WifiCertService::DeleteCert(int32_t aId, const nsAString & aCertNickname)
> +{
> + RefPtr<CryptoTask> task = new DeleteCertTask(aId, aCertNickname);
> + task->Dispatch("WifiDeleteCert");
NIT: return task->Dispatch("WifiDeleteCert");
Attachment #8371281 -
Flags: review?(brian) → review+
Assignee | ||
Comment 28•11 years ago
|
||
Inline nssUtil.DeleteCert() and fix nits per comment 27.
Attachment #8371281 -
Attachment is obsolete: true
Updated•11 years ago
|
Whiteboard: [FT:RIL]
Assignee | ||
Comment 30•11 years ago
|
||
Update to webIDL.
Attachment #8371280 -
Attachment is obsolete: true
Attachment #8406733 -
Flags: review?(mrbkap)
Assignee | ||
Comment 31•11 years ago
|
||
Update to webIDL, use new interface.
Attachment #8392707 -
Attachment is obsolete: true
Attachment #8406734 -
Flags: review?(mrbkap)
Assignee | ||
Comment 32•11 years ago
|
||
Rebase based on bug 917176.
Attachment #8406734 -
Attachment is obsolete: true
Attachment #8406734 -
Flags: review?(mrbkap)
Attachment #8408110 -
Flags: review?(mrbkap)
Updated•11 years ago
|
Attachment #8406733 -
Flags: review?(mrbkap) → review+
Updated•11 years ago
|
Attachment #8408110 -
Flags: review?(mrbkap) → review+
Assignee | ||
Updated•11 years ago
|
Attachment #8379617 -
Attachment description: 0002. Backend. V6 → 0002. Backend. V6. r=mrbkap,briansmith
Assignee | ||
Updated•11 years ago
|
Attachment #8406733 -
Attachment description: 0001. WebIDL Change → 0001. WebIDL Change. r=mrbkap
Assignee | ||
Comment 34•11 years ago
|
||
Attachment #8410919 -
Attachment is obsolete: true
Assignee | ||
Comment 36•10 years ago
|
||
Try result : https://tbpl.mozilla.org/?tree=Try&rev=b586311119d2
This is third bug to check in.
Keywords: checkin-needed
Comment 37•10 years ago
|
||
https://hg.mozilla.org/integration/b2g-inbound/rev/6781b96cca1c
https://hg.mozilla.org/integration/b2g-inbound/rev/947690de7b62
https://hg.mozilla.org/integration/b2g-inbound/rev/8f803659229a
Keywords: checkin-needed
Comment 38•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/6781b96cca1c
https://hg.mozilla.org/mozilla-central/rev/947690de7b62
https://hg.mozilla.org/mozilla-central/rev/8f803659229a
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Updated•10 years ago
|
Target Milestone: --- → 2.0 S1 (9may)
Updated•10 years ago
|
feature-b2g: --- → 2.0
Updated•10 years ago
|
blocking-b2g: backlog → ---
tracking-b2g:
--- → backlog
You need to log in
before you can comment on or make changes to this bug.
Description
•