我正在尝试使用下一代码从Android系统存储中导入私钥:
PrivateKey privateKey = KeyChain.getPrivateKey(activity, alias);
Run Code Online (Sandbox Code Playgroud)
其中alias使用检索KeyChain.choosePrivateKeyAlias()方法.KeyChain.getPrivateKey不返回null但PrivateKey对象包含错误的键(所有重要字段都是null).我认为密钥不可导出,并尝试在下一个代码中使用它:
Cipher rsa;
rsa = Cipher.getInstance("RSA");
rsa.init(Cipher.ENCRYPT_MODE, privateKey);
byte[] enc = rsa.doFinal(str.getBytes());
Run Code Online (Sandbox Code Playgroud)
但得到了来自BouncyCastle内部的NullPointerException.
带有密钥的证书是使用来自存储卡功能的Android标准负载从 PFX文件导入的.
我做错了什么?
UPD:我试过用不同的RSA证书做同样的事情,结果是一样的:(
我正在尝试在本地主机上配置 Shibboleth 服务提供程序和身份提供程序以进行测试。
问题是,当我尝试访问受保护的资源时,出现“无法找到身份提供者的元数据”错误。
我已经阅读了与软件配置和此特定错误修复相关的所有教程和讨论,但对我来说没有任何作用。
SP 的 shibboleth2.xml 配置:
<SPConfig xmlns="urn:mace:shibboleth:2.0:native:sp:config"
xmlns:conf="urn:mace:shibboleth:2.0:native:sp:config"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
clockSkew="180">
<InProcess logger="native.logger">
<ISAPI normalizeRequest="true" safeHeaderNames="true">
<Site id="1" name="localhost" />
</ISAPI>
</InProcess>
<TCPListener address="127.0.0.1" port="1600" acl="127.0.0.1" />
<StorageService type="Memory" id="mem" cleanupInterval="900" />
<SessionCache type="StorageService" StorageService="mem" cacheAssertions="false" cacheAllowance="900" inprocTimeout="900" cleanupInterval="900" />
<ReplayCache StorageService="mem" />
<ArtifactMap artifactTTL="180" />
<RequestMapper type="Native">
<RequestMap>
<Host name="localhost">
<Path name="secure" authType="shibboleth" requireSession="true"/>
</Host>
</RequestMap>
</RequestMapper>
<ApplicationDefaults id="default" policyId="default"
entityID="http://localhost/secure"
homeURL="http://localhost/secure"
signing="false" encryption="false"
REMOTE_USER="eppn persistent-id targeted-id">
<Sessions lifetime="28800" timeout="3600" relayState="ss:mem" handlerURL="/Shibboleth.sso"
checkAddress="false" handlerSSL="false" …Run Code Online (Sandbox Code Playgroud) android ×1
bouncycastle ×1
eclipse ×1
java ×1
jce ×1
opensaml ×1
saml ×1
saml-2.0 ×1
shibboleth ×1