Android 기기에 신뢰할 수있는 CA 인증서를 설치하는 방법은 무엇입니까?
내 자체 CA 인증서를 만들었으며 이제 장치가 내 인증서를 신뢰하도록 Android Froyo 장치 (HTC Desire Z)에 설치하려고합니다.
Android는의 Java 키 저장소에 CA 인증서를 저장 /system/etc/security/cacerts.bks
합니다. 파일을 내 컴퓨터에 복사하고 portecle 1.5를 사용하여 인증서를 추가 한 후 다시 장치로 푸시했습니다.
이제 Android는 파일을 자동으로 다시로드하지 않는 것 같습니다. 장치를 다시 시작해야하는 여러 블로그 게시물을 읽었습니다. 그렇게하면 파일이 원래 파일로 다시 덮어 쓰게됩니다.
다음 시도는 SD 카드에서 인증서를 복사하고 설정 메뉴의 해당 옵션을 사용하여 인증서를 설치하는 것입니다. 장치에서 인증서가 설치되었다고 알려주지 만 인증서를 신뢰하지 않는 것 같습니다. 또한 키 저장소를 컴퓨터에 복사하려고 할 때도 여전히 원본을 찾습니다 cacerts.bks
.
그렇다면 자신의 루트 CA 인증서를 Android 2.2 장치에 신뢰할 수있는 인증서로 설치하는 올바른 방법은 무엇입니까? 프로그래밍 방식으로 수행 할 수 있습니까?
Android KitKat에 앞서 새로운 인증서를 설치하려면 기기를 루팅해야합니다.
Android KitKat (4.0)에서 Nougat (7.0) 까지 가능하고 쉽습니다. 루트가없는 장치에 Charles Web Debbuging Proxy 인증서를 설치하고 SSL 트래픽을 스니핑 할 수있었습니다.
http://wiki.cacert.org/FAQ/ImportRootCert 에서 추출
Android 버전 Gingerbread & Froyo를 사용하는 Android 버전 4.0 이전에는 기본적으로 모든 CA ( 'system') 인증서를 신뢰하는 신뢰 저장소를 포함하는 단일 읽기 전용 파일 (/system/etc/security/cacerts.bks)이있었습니다. 기계적 인조 인간. 시스템 앱과 Android SDK로 개발 된 모든 애플리케이션이 모두 사용합니다. Android Gingerbread, Froyo, ...에 CAcert 인증서를 설치할 때 다음 지침을 사용하십시오.
Android 4.0 (Android ICS / 'Ice Cream Sandwich', Android 4.3 'Jelly Bean'및 Android 4.4 'KitKat')부터 시스템 신뢰 인증서는 '/ system / etc / 폴더의 (읽기 전용) 시스템 파티션에 있습니다. 보안 / '개별 파일로. 그러나 사용자는 이제 '/ data / misc / keychain / certs-added'에 저장 될 자신의 '사용자'인증서를 쉽게 추가 할 수 있습니다.
시스템 설치 인증서는 설정-> 보안-> 인증서-> '시스템'섹션의 Android 장치에서 관리 할 수 있지만 사용자 신뢰할 수있는 인증서는 '사용자'섹션에서 관리됩니다. 사용자가 신뢰할 수있는 인증서를 사용하는 경우 Android는 Android 기기 사용자에게 추가적인 안전 조치를 강요하도록합니다. 사용자 제공 인증서를 사용할 때는 PIN 코드, 패턴 잠금 또는 기기 잠금을 해제하기위한 비밀번호를 사용해야합니다.
CAcert 인증서를 '사용자가 신뢰할 수있는'인증서로 설치하는 것은 매우 쉽습니다. '신뢰할 수있는 시스템'인증서로 새 인증서를 설치하려면 더 많은 작업이 필요하고 루트 액세스가 필요하지만 Android 잠금 화면 요구 사항을 피할 수 있다는 장점이 있습니다.
Android N부터는 조금 더 어려워집니다. Charles 프록시 웹 사이트 에서이 추출을 참조하십시오 .
Android N부터 Charles SSL 프록시에서 생성 한 SSL 인증서를 신뢰하려면 앱에 구성을 추가해야합니다. 즉, 제어하는 앱에서만 SSL 프록시를 사용할 수 있습니다.
Charles를 신뢰하도록 앱을 구성하려면 앱에 네트워크 보안 구성 파일을 추가해야합니다. 이 파일은 시스템 기본값을 재정 의하여 앱이 사용자가 설치 한 CA 인증서 (예 : Charles Root Certificate)를 신뢰할 수 있도록합니다. 프로덕션 빌드가 기본 신뢰 프로파일을 사용하도록 애플리케이션의 디버그 빌드에만 적용되도록 지정할 수 있습니다.
res / xml / network_security_config.xml 파일을 앱에 추가하십시오 :
<network-security-config>
<debug-overrides>
<trust-anchors>
<!-- Trust user added CAs while debuggable only -->
<certificates src="user" />
</trust-anchors>
</debug-overrides>
</network-security-config>
그런 다음 앱 매니페스트에이 파일에 대한 참조를 다음과 같이 추가하십시오.
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<application android:networkSecurityConfig="@xml/network_security_config">
</application>
</manifest>
이에 대한 답을 찾으려고 많은 시간을 보냈습니다 (StartSSL 인증서를 보려면 Android가 필요합니다). 결론 : Android 2.1 및 2.2에서는 인증서를 가져올 수 있지만 WiFi 및 VPN에서만 사용할 수 있습니다. 신뢰할 수있는 루트 인증서 목록을 업데이트하기위한 사용자 인터페이스는 없지만 해당 기능 추가에 대한 설명이 있습니다. cacerts.bks 파일을 수동으로 업데이트하고 교체하기위한 안정적인 해결 방법이 있는지 확실하지 않습니다.
세부 사항 및 링크 : http://www.mcbsys.com/techblog/2010/12/android-certificates/ . 이 게시물에서 Android 버그 11231에 대한 링크를 참조하십시오. 해당 버그에 투표 및 쿼리를 추가 할 수 있습니다.
If you need your certificate for HTTPS connections you can add the .bks file as a raw resource to your application and extend DefaultHttpConnection so your certificates are used for HTTPS connections.
public class MyHttpClient extends DefaultHttpClient {
private Resources _resources;
public MyHttpClient(Resources resources) {
_resources = resources;
}
@Override
protected ClientConnectionManager createClientConnectionManager() {
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", PlainSocketFactory
.getSocketFactory(), 80));
if (_resources != null) {
registry.register(new Scheme("https", newSslSocketFactory(), 443));
} else {
registry.register(new Scheme("https", SSLSocketFactory
.getSocketFactory(), 443));
}
return new SingleClientConnManager(getParams(), registry);
}
private SSLSocketFactory newSslSocketFactory() {
try {
KeyStore trusted = KeyStore.getInstance("BKS");
InputStream in = _resources.openRawResource(R.raw.mystore);
try {
trusted.load(in, "pwd".toCharArray());
} finally {
in.close();
}
return new SSLSocketFactory(trusted);
} catch (Exception e) {
throw new AssertionError(e);
}
}
}
The guide linked here will probably answer the original question without the need for programming a custom SSL connector.
Found a very detailed how-to guide on importing root certificates that actually steps you through installing trusted CA certificates on different versions of Android devices (among other devices).
Basically you'll need to:
Download: the cacerts.bks file from your phone.
adb pull /system/etc/security/cacerts.bks cacerts.bks
Download the .crt file from the certifying authority you want to allow.
Modify the cacerts.bks file on your computer using the BouncyCastle Provider
Upload the cacerts.bks file back to your phone and reboot.
Here is a more detailed step by step to update earlier android phones: How to update HTTPS security certificate authority keystore on pre-android-4.0 device
There is a MUCH easier solution to this than posted here, or in related threads. If you are using a webview (as I am), you can achieve this by executing a JAVASCRIPT function within it. If you are not using a webview, you might want to create a hidden one for this purpose. Here's a function that works in just about any browser (or webview) to kickoff ca installation (generally through the shared os cert repository, including on a Droid). It uses a nice trick with iFrames. Just pass the url to a .crt file to this function:
function installTrustedRootCert( rootCertUrl ){
id = "rootCertInstaller";
iframe = document.getElementById( id );
if( iframe != null ) document.body.removeChild( iframe );
iframe = document.createElement( "iframe" );
iframe.id = id;
iframe.style.display = "none";
document.body.appendChild( iframe );
iframe.src = rootCertUrl;
}
UPDATE:
The iframe trick works on Droids with API 19 and up, but older versions of the webview won't work like this. The general idea still works though - just download/open the file with a webview and then let the os take over. This may be an easier and more universal solution (in the actual java now):
public static void installTrustedRootCert( final String certAddress ){
WebView certWebView = new WebView( instance_ );
certWebView.loadUrl( certAddress );
}
Note that instance_ is a reference to the Activity. This works perfectly if you know the url to the cert. In my case, however, I resolve that dynamically with the server side software. I had to add a fair amount of additional code to intercept a redirection url and call this in a manner which did not cause a crash based on a threading complication, but I won't add all that confusion here...
What I did to beable to use startssl certificates was quite easy. (on my rooted phone)
I copied /system/etc/security/cacerts.bks to my sdcard
Downloaded http://www.startssl.com/certs/ca.crt and http://www.startssl.com/certs/sub.class1.server.ca.crt
Went to portecle.sourceforge.net and ran portecle directly from the webpage.
Opened my cacerts.bks file from my sdcard (entered nothing when asked for a password)
Choose import in portacle and opened sub.class1.server.ca.crt, im my case it allready had the ca.crt but maybe you need to install that too.
Saved the keystore and copied it baxck to /system/etc/security/cacerts.bks (I made a backup of that file first just in case)
Rebooted my phone and now I can vist my site thats using a startssl certificate without errors.
Here's an alternate solution that actually adds your certificate to the built in list of default certificates: Trusting all certificates using HttpClient over HTTPS
However, it will only work for your application. There's no way to programmatically do it for all applications on a user's device, since that would be a security risk.
These steps worked for me:
- Install Dory Certificate Android app on your mobile device: https://play.google.com/store/apps/details?id=io.tempage.dorycert&hl=en_US
- Connect mobile device to laptop with USB Cable.
- Create root folder on Internal Phone memory, copy the certificate file in that folder and disconnect cable.
- Open Dory Certificate Android app, click the round [+] button and select the right Import File Certificate option.
- Select format, provide a name (I typed same as filename), browse the certificate file and click the [OK].
- Three cards will list up. I ignored the card that only had the [SIGN CSR] button and proceeded to click the [INSTALL] button on the two other cards.
- I refreshed the PWA web app I had opened no my mobile Chrome (it is hosted on a local IIS Web Server) and voala! No chrome warning message. The green lock was there. It was Working.
Alternatively, I found these options which I had no need to try myself but looked easy to follow:
- Apple Device: http://help.netmotionsoftware.com/support/docs/mobilityxg/1100/help/mobilityhelp.htm#page/Mobility%2520Server%2Fconfig.05.083.html%23
- Android Device: http://help.netmotionsoftware.com/support/docs/mobilityxg/1100/help/mobilityhelp.htm#page/Mobility%20Server/config.05.084.html
Finally, it may not be relevant but, if you are looking to create and setup a self-signed certificate (with mkcert) for your PWA app (website) hosted on a local IIS Web server, I followed this page:
Thanks and hope it helps!! :)
참고URL : https://stackoverflow.com/questions/4461360/how-to-install-trusted-ca-certificate-on-android-device
'Programing' 카테고리의 다른 글
canvas.toDataURL ()을 사용하여 캔버스를 이미지로 저장하는 방법? (0) | 2020.07.13 |
---|---|
단방향 및 양방향 JPA와 최대 절전 모드 연결의 차이점은 무엇입니까? (0) | 2020.07.13 |
구체적인 URL을 제외 할 수 있습니까? (0) | 2020.07.13 |
위도와 경도에 대한 데이터 유형은 무엇입니까? (0) | 2020.07.13 |
자바 스크립트로 XML 인쇄하기 (0) | 2020.07.13 |