android.security.KeyChainException:java.lang.IllegalStateException:UID [英] android.security.KeyChainException: java.lang.IllegalStateException: uid

查看:2224
本文介绍了android.security.KeyChainException:java.lang.IllegalStateException:UID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:

  android.security.KeyChainException:java.lang.IllegalStateException:UID 10111没有权限访问请求的别名

code:

 新主题(新的Runnable(){        公共无效的run(){
            尝试{
                X509证书[] = myCertificates KeyChain.getCertificateChain(MainActivity.thisServerCertificate);
                如果(myCertificates!= NULL)
                {
                    的System.out.println(myCertificates大小+ myCertificates.length);                    的for(int i = 0; I< myCertificates.length;我++)
                    {
                        的System.out.println(myCertificates我=+ I ++ myCertificates [I]);
                    }
                }
            }赶上(KeyChainException E){
                // TODO自动生成catch块
                e.printStackTrace();
            }赶上(InterruptedException的E){
                // TODO自动生成catch块
                e.printStackTrace();
            }
            赶上(例外五){
                // TODO自动生成catch块
                e.printStackTrace();
            }
        }
    })。开始();


解决方案

钥匙链类需要应用程序调用 choosePrivateKeyAlias​​()至少一次应用程序之前调用安装在 getPrivateKey() getCertificateChain()。因此,即使一个事先知道的别名,在 choosePrivateKeyAlias​​()必须至少调用一次,否则就没有应用程序和内部数据库<$ C之间建立信任$ C>钥匙链使用。

Error:

android.security.KeyChainException: java.lang.IllegalStateException: uid 10111 doesn't have permission to access the requested alias

Code:

new Thread(new Runnable() {

        public void run() {
            try {
                X509Certificate[] myCertificates=KeyChain.getCertificateChain(MainActivity.this, "ServerCertificate");
                if(myCertificates!=null)
                {
                    System.out.println("myCertificates size "+myCertificates.length);

                    for(int i=0;i<myCertificates.length;i++)
                    {
                        System.out.println("myCertificates i= "+i+"    "+myCertificates[i]);
                    }
                }
            } catch (KeyChainException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }).start();

解决方案

The KeyChain class requires the application to call choosePrivateKeyAlias() at least once after the application is installed before calling getPrivateKey() or getCertificateChain(). So even if one knows the alias beforehand, the choosePrivateKeyAlias() must be called at least once, otherwise there is no trust established between the app and the internal database that KeyChain uses.

这篇关于android.security.KeyChainException:java.lang.IllegalStateException:UID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆