1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_ANDROID_NETWORK_LIBRARY_H_
6 #define NET_ANDROID_NETWORK_LIBRARY_H_
13 #include "base/basictypes.h"
14 #include "net/android/cert_verify_result_android.h"
15 #include "net/base/mime_util.h"
16 #include "net/base/net_export.h"
21 // |cert_chain| is DER encoded chain of certificates, with the server's own
22 // certificate listed first.
23 // |auth_type| is as per the Java X509Certificate.checkServerTrusted method.
24 CertVerifyResultAndroid
VerifyX509CertChain(
25 const std::vector
<std::string
>& cert_chain
,
26 const std::string
& auth_type
);
28 // Adds a certificate as a root trust certificate to the trust manager.
29 // |cert| is DER encoded certificate, |len| is its length in bytes.
30 void AddTestRootCertificate(const uint8
* cert
, size_t len
);
32 // Removes all root certificates added by |AddTestRootCertificate| calls.
33 void ClearTestRootCertificates();
35 // Helper for the <keygen> handler. Passes the DER-encoded key pair via
36 // JNI to the Credentials store. Note that the public key must be a DER
37 // encoded SubjectPublicKeyInfo (X.509), as returned by i2d_PUBKEY()
38 // (and *not* i2d_PublicKey(), which returns a PKCS#1 key).
40 // Also, the private key must be in PKCS#8 format, as returned by
41 // i2d_PKCS8_PRIV_KEY_INFO(EVP_PKEY2PKCS8(pkey)), which is a different
42 // format than what i2d_PrivateKey() returns, so don't use it either.
44 bool StoreKeyPair(const uint8
* public_key
,
46 const uint8
* private_key
,
49 // Helper used to pass the DER-encoded bytes of an X.509 certificate or
50 // a PKCS#12 archive holding a private key to the CertInstaller activity.
51 NET_EXPORT
void StoreCertificate(net::CertificateMimeType cert_type
,
55 // Returns true if it can determine that only loopback addresses are configured.
56 // i.e. if only 127.0.0.1 and ::1 are routable.
57 // Also returns false if it cannot determine this.
58 bool HaveOnlyLoopbackAddresses();
60 // Return a string containing a list of network interfaces, each item is a
61 // network name and address pair.
62 // e.g. "eth0,10.0.0.2;eth0,fe80::5054:ff:fe12:3456" is a result string
63 // containing two items.
64 std::string
GetNetworkList();
66 // Get the mime type (if any) that is associated with the file extension.
67 // Returns true if a corresponding mime type exists.
68 bool GetMimeTypeFromExtension(const std::string
& extension
,
71 // Register JNI methods
72 NET_EXPORT
bool RegisterNetworkLibrary(JNIEnv
* env
);
74 } // namespace android
77 #endif // NET_ANDROID_NETWORK_LIBRARY_H_