Skip to content

Add a data getter to X509Certificate #33115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zanderso opened this issue May 14, 2018 · 12 comments
Closed

Add a data getter to X509Certificate #33115

zanderso opened this issue May 14, 2018 · 12 comments
Assignees
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-enhancement A request for a change that isn't a bug

Comments

@zanderso
Copy link
Member

Add a data getter to X509Certificate that returns the DER encoded bytes of the certificate from i2d_X509() as an UnmodifiableUint8List.

This is to enable SSL pinning.

/cc @mit-mit @a-siva

@zanderso zanderso added area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-enhancement A request for a change that isn't a bug labels May 14, 2018
@mit-mit
Copy link
Member

mit-mit commented May 14, 2018

Related Flutter bug: flutter/flutter#16066

@zanderso zanderso assigned zanderso and unassigned bkonyi May 16, 2018
@zanderso
Copy link
Member Author

https://dart-review.googlesource.com/c/sdk/+/55505

I'll land after adding a getter for the sha1, which is what I think you mean by fingerprint.

@zanderso
Copy link
Member Author

It should make it in the next roll into Flutter top-of-tree. I'll link the pull request to follow when it shows up.

@jamespet77
Copy link

Is this available in the beta release of Flutter yet? or where can I pull this source?

@zanderso
Copy link
Member Author

zanderso commented Aug 2, 2018

Sorry for not updating. This is now available in Flutter.

@jamespet77
Copy link

I'm pretty new to flutter. Can someone point me towards a tutorial or a doc that describes how to use this.

@zoechi
Copy link
Contributor

zoechi commented Aug 3, 2018

@linuxjet did you check the test

void checkServerCertificate(X509Certificate serverCert) {
String serverCertString = serverCert.pem;
String certFile =
new File(localFile('certificates/server_chain.pem')).readAsStringSync();
Expect.isTrue(certFile.contains(serverCertString));
// Computed with:
// openssl x509 -noout -sha1 -fingerprint -in certificates/server_chain.pem
List<int> serverSha1 = <int>[
0xB3, 0x01, 0xCB, 0x7E, 0x6F, 0xEF, 0xBE, 0xEF, //
0x75, 0x6D, 0xA8, 0x80, 0x60, 0xA8, 0x5D, 0x6F, //
0xC4, 0xED, 0xCD, 0x48, //
];
Expect.listEquals(serverSha1, serverCert.sha1);
}
Future testClient(server) {
return SecureSocket
.connect(HOST, server.port, context: clientContext)
.then((socket) {
checkServerCertificate(socket.peerCertificate);
socket.write("Hello server.");
socket.close();
return socket.fold(<int>[], (message, data) => message..addAll(data)).then(
(message) {
Expect.listEquals("Hello server.".codeUnits, message);
return server;
});
});
}
(can't help more)

@jamespet77
Copy link

HA!.. no I didn't. because I didn't see it. thx

@qwilbird
Copy link

Hi,
what about public key pinning (HPKP). Can the SecurityContext validate a public key instead of a certificate? This is more future proof as certificate pinning comes with issues of certificate expiry
Cheers

@daadu
Copy link

daadu commented Feb 16, 2019

any update on SSL pinning with public key?

@a-siva
Copy link
Contributor

a-siva commented Feb 19, 2019

Can we file a new feature request for SLL pinning with public key, this issue was opened for adding 'data' getter which is done and the issue closed.

@sandeepcmsm
Copy link

issue opened for ssl public key pinning support. #35981

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-io type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

9 participants