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

Issue 1965313002: JNI+mm: Generate certificate if non-default key type is specified. (Closed)

Created:
4 years, 7 months ago by hbos
Modified:
4 years, 7 months ago
CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com, mattdr
Base URL:
https://chromium.googlesource.com/external/webrtc.git@master
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

JNI+mm: Generate certificate if non-default key type is specified. By comparing key type with KT_DEFAULT we remove the implicit assumption that the default is RSA. Removing the assumptions about what the default is is necessary for a follow-up CL that will change the default. BUG=webrtc:5795, webrtc:5707 R=hta@webrtc.org, magjed@webrtc.org, tommi@webrtc.org TBR=tkchin@webrtc.org Committed: https://crrev.com/e06c2ddbdea7cfdeae82c3a7ae9f9ea2978f7394 Cr-Commit-Position: refs/heads/master@{#12722}

Patch Set 1 #

Total comments: 3

Patch Set 2 : jni returning null instead #

Total comments: 2

Patch Set 3 : mm: nativeConfiguration logging and returning null on failure #

Patch Set 4 : Rebase with master #

Total comments: 14
Unified diffs Side-by-side diffs Delta from patch set Stats (+69 lines, -53 lines) Patch
M webrtc/api/java/jni/peerconnection_jni.cc View 1 2 chunks +11 lines, -13 lines 0 comments Download
M webrtc/base/sslidentity.h View 1 chunk +0 lines, -3 lines 0 comments Download
M webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm View 1 2 3 3 chunks +35 lines, -20 lines 8 comments Download
M webrtc/sdk/objc/Framework/Classes/RTCConfiguration+Private.h View 1 2 1 chunk +1 line, -1 line 2 comments Download
M webrtc/sdk/objc/Framework/Classes/RTCPeerConnection.mm View 1 2 2 chunks +10 lines, -4 lines 4 comments Download
M webrtc/sdk/objc/Framework/UnitTests/RTCConfigurationTest.mm View 1 2 3 1 chunk +12 lines, -12 lines 0 comments Download

Messages

Total messages: 36 (15 generated)
hbos
Please take a look, magjed, hta and mattdr.
4 years, 7 months ago (2016-05-11 10:09:21 UTC) #5
magjed_webrtc
https://codereview.webrtc.org/1965313002/diff/1/webrtc/api/java/jni/peerconnection_jni.cc File webrtc/api/java/jni/peerconnection_jni.cc (right): https://codereview.webrtc.org/1965313002/diff/1/webrtc/api/java/jni/peerconnection_jni.cc#newcode1575 webrtc/api/java/jni/peerconnection_jni.cc:1575: RTC_CHECK(certificate); If this can ever fail, I think it's ...
4 years, 7 months ago (2016-05-12 08:04:08 UTC) #7
hta-webrtc
Need to decide on the crash vs throw thing. Java seems to like throwing exceptions, ...
4 years, 7 months ago (2016-05-12 08:12:25 UTC) #8
hbos
PTAL magjed, hta. https://codereview.webrtc.org/1965313002/diff/1/webrtc/api/java/jni/peerconnection_jni.cc File webrtc/api/java/jni/peerconnection_jni.cc (right): https://codereview.webrtc.org/1965313002/diff/1/webrtc/api/java/jni/peerconnection_jni.cc#newcode1575 webrtc/api/java/jni/peerconnection_jni.cc:1575: RTC_CHECK(certificate); On 2016/05/12 08:12:25, hta-webrtc wrote: ...
4 years, 7 months ago (2016-05-12 08:27:08 UTC) #9
hbos
https://codereview.webrtc.org/1965313002/diff/20001/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm File webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm (right): https://codereview.webrtc.org/1965313002/diff/20001/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm#newcode97 webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm:97: RTC_CHECK(certificate); On 2016/05/12 08:27:08, hbos wrote: > Here I ...
4 years, 7 months ago (2016-05-12 08:39:08 UTC) #10
hbos
PTAL magjed, hta. Handling generation failure (though unlikely) in both jni and mm case.
4 years, 7 months ago (2016-05-12 09:53:59 UTC) #11
magjed_webrtc
webrtc/api/java/jni/peerconnection_jni.cc lgtm
4 years, 7 months ago (2016-05-12 10:00:31 UTC) #12
hta-webrtc
lgtm
4 years, 7 months ago (2016-05-12 11:40:27 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1965313002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1965313002/60001
4 years, 7 months ago (2016-05-12 11:43:32 UTC) #15
commit-bot: I haz the power
Try jobs failed on following builders: android_dbg on tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/android_dbg/builds/13247)
4 years, 7 months ago (2016-05-12 11:52:26 UTC) #17
hbos
Please take a look, tkchin.
4 years, 7 months ago (2016-05-12 11:57:00 UTC) #19
tommi
lgtm
4 years, 7 months ago (2016-05-13 11:03:28 UTC) #22
hbos
On 2016/05/13 11:03:28, tommi-webrtc wrote: > lgtm With this I'll TBR=tkchin and land. Important for ...
4 years, 7 months ago (2016-05-13 11:06:31 UTC) #23
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1965313002/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1965313002/60001
4 years, 7 months ago (2016-05-13 11:07:31 UTC) #26
commit-bot: I haz the power
Patchset 4 (id:??) landed as https://crrev.com/e06c2ddbdea7cfdeae82c3a7ae9f9ea2978f7394 Cr-Commit-Position: refs/heads/master@{#12722}
4 years, 7 months ago (2016-05-13 11:50:55 UTC) #30
hbos
Committed patchset #4 (id:60001) manually as e06c2ddbdea7cfdeae82c3a7ae9f9ea2978f7394 (presubmit successful).
4 years, 7 months ago (2016-05-13 11:50:57 UTC) #31
tkchin_webrtc
When is the EC default launch? I thought TBRs were reserved for build emergencies or ...
4 years, 7 months ago (2016-05-13 17:48:06 UTC) #32
tommi
On 2016/05/13 17:48:06, tkchin_webrtc wrote: > When is the EC default launch? I thought TBRs ...
4 years, 7 months ago (2016-05-13 17:50:48 UTC) #33
tkchin_webrtc
On 2016/05/13 17:50:48, tommi-webrtc wrote: > On 2016/05/13 17:48:06, tkchin_webrtc wrote: > > When is ...
4 years, 7 months ago (2016-05-13 18:06:49 UTC) #34
tkchin_webrtc
https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm File webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm (right): https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm#newcode79 webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm:79: std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> On 2016/05/13 17:48:05, tkchin_webrtc wrote: > Are we ...
4 years, 7 months ago (2016-05-13 18:07:39 UTC) #35
hbos
4 years, 7 months ago (2016-05-16 12:49:05 UTC) #36
Message was sent while issue was closed.
Comments addressed in this follow-up CL:
https://codereview.webrtc.org/1978233002/

Will copy this reply to comments so that the discussion can continue there.

https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework...
File webrtc/sdk/objc/Framework/Classes/RTCConfiguration+Private.h (right):

https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework...
webrtc/sdk/objc/Framework/Classes/RTCConfiguration+Private.h:24:
webrtc::PeerConnectionInterface::RTCConfiguration* nativeConfiguration;
On 2016/05/13 17:48:05, tkchin_webrtc wrote:
> RTCConfiguration *nativeConfiguration;
> 
> This should be a method instead of a property because it is actually creating
an
> object that needs to be released or at the very least commented to indicate
that
> manual memory management is required. The style is to prefix with "create".
> 
> - (webrtc::PeerConnectionInterface::RTCConfiguration
> *)createNativeConfiguration;

Done.

https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework...
File webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm (right):

https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework...
webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm:78: -
(webrtc::PeerConnectionInterface::RTCConfiguration*)nativeConfiguration {
On 2016/05/13 17:48:05, tkchin_webrtc wrote:
> RTCConfiguration *)

Done.

https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework...
webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm:79:
std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration>
On 2016/05/13 18:07:38, tkchin_webrtc wrote:
> On 2016/05/13 17:48:05, tkchin_webrtc wrote:
> > Are we returning a pointer to avoid memory copy? Or to surface an error with
> > certificate generation? Why don't we want a default fallback?

To say that we failed to generate the configuration asked for (surface
certificate failure).
As for attempting to generate a different certificate as a fallback, if you
choose ECDSA over RSA for security reasons it may(?) be bad if you implicitly
end up with an RSA certificate.

> > This will cause RTCPeerConnectionFactory to potentially return nil on init,
> > which isn't great because it's like saying your constructor failed.
> > We generally reserve returning nil on init for fairly exceptional
> circumstances
> > - when is certificate generation expected to fail?

Under very rare circumstances. I don't know how to make it fail or if this ever
happens in practice. Our unittests EXPECT generate certificate to return a
certificate and I haven't ever seen the unittest failing to produce one. But the
lower-level crypto libraries could return null and that is propagated by the
interface instead of crashing.

> > It may be better for RTCConfiguration to store a copy of the C++ object on
> init,
> > so RTCConfiguration is the object that returns nil on init instead, which
> makes
> > more sense, and will be caught by assertions in RTCPeerConnectionFactory.
> 
> and by factory I meant peerconnection's private
initWithFactory:configuration...
> method :)
> which I guess isn't so bad because it's private and within our control.

Do you mean to move the GenerateCertificate code from createNativeConfiguration
to RTCConfiguration's init? That would make _keyType pointless, and it should
then be removed or be made const? If we don't move the code we have the option
to modify the default value of _keyType to support other certificates.

In both cases we end up with an init that could conceivably return nil.
Alternatively we could add an assertion that GenerateCertificate does not fail
and change the code back so that we do not propagate the error.

What do you think I should do? Currently I did not change this and still have
createNativeConfiguration.

https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework...
webrtc/sdk/objc/Framework/Classes/RTCConfiguration.mm:108:
RTCLogWarning(@"Failed to generate certificate.");
On 2016/05/13 18:07:38, tkchin_webrtc wrote:
> On 2016/05/13 17:48:05, tkchin_webrtc wrote:
> > this is an error because you will fail to create things like factory
> > RTCLogError
> 
> I meant peerconnection via [factory peerconnectionWithConfiguration..]

RTCLogError - Done.

https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework...
File webrtc/sdk/objc/Framework/Classes/RTCPeerConnection.mm (right):

https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework...
webrtc/sdk/objc/Framework/Classes/RTCPeerConnection.mm:203: return nullptr;
On 2016/05/13 17:48:06, tkchin_webrtc wrote:
> ObjC style requires braces
> 
> nil not nullptr. 
> if (!nativeConfiguration) {
>   return nil;
> }

Done.

https://codereview.webrtc.org/1965313002/diff/60001/webrtc/sdk/objc/Framework...
webrtc/sdk/objc/Framework/Classes/RTCPeerConnection.mm:259: return false;
On 2016/05/13 17:48:06, tkchin_webrtc wrote:
> BOOL is not a boolean
> 
> if (!nativeConfiguration) {
>   return NO;
> }

Done.

Powered by Google App Engine
This is Rietveld 408576698