小编Wag*_*gga的帖子

Android使用自签名客户端证书身份验证连接到IIS中的WCF休息服务

问候,

我正在尝试创建一个Android测试应用程序,它只执行以下操作'使用自签名客户端证书身份验证连接到IIS中的JSON WCF休息服务',但是当我运行时,我一直收到"禁止访问"应用程序.WCF服务的客户端WCF似乎工作正常,当我禁用"需要客户端证书"时,WCF服务的Android客户端应用程序也可以正常工作.

奇怪的是,Eclipse通知已找到客户端证书,并且使用它创建了KeyManager,但没有任何内容发送到服务器.

已对自签名证书采取以下步骤

  1. 使用serverCA.cer和clientCA.cer作为子证书创建了一个rootCA.cer
  2. 已从clientCA.cer创建私钥信息
  3. 使用Portecle,两个密钥库以BKS格式创建,一个包含clientCA的PKI,名为keystore.bks,另一个包含rootCA作为条目的truststore.bks
  4. PKI具有别名客户端,用于仔细检查是否可以检索PKI
  5. truststore.bks包含rootCA.cer
  6. 这两个密钥库都添加在Android的Eclipse的res/raw中



为了处理Android中的自签名证书,我尝试使用几个例子,但StackOverflow的EasySSLSocketFactory和EasySSLTrustManager :self-signed-ssl-acceptance-android大部分都有效.我还尝试使用默认的keytool创建密钥库,但是这会导致创建更多不正确的密钥库.




更新2011-03-17:系统信息
承载IIS的系统操作系统是带有.NET 4.0的IIS-5的Windows XP.IIS中的服务将serverCA.cer指定为服务器证书,并启用了require客户端证书.

我正在使用的Android版本是2.3.3,并且已经设置了Internet的权限,并且在Eclipse项目中添加了keystore和truststore作为原始资源.

另外,当我在调试模式中查找KeyManagerFactory.getKeyManagers()返回的内容时,我看到列表中有一个项目.


以下是我对该问题使用的操作/代码的详细信息:

证书是使用makecert创建的,因为它首先必须在WCF服务和客户端之间工作.

makecert.exe -r -n "CN=rootCA,O=Organization,OU=Org Unit,L=Location,S=SH,C=Country" -pe -ss root -sr LocalMachine -sky exchange -m 96 -a sha1 -len 2048 rootCA.cer -sv rootCA.pvk
makecert.exe -n "CN=serverCA" -pe -ss my -sr LocalMachine -sky exchange -m 96 -in "rootCA" -is root -ir LocalMachine -a sha1 -eku 1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2 serverCA.cer
makecert.exe -n "CN=clientCA" -pe -ss my -sr CurrentUser -sky exchange -m 96 …
Run Code Online (Sandbox Code Playgroud)

authentication wcf android json client-certificates

5
推荐指数
1
解决办法
3483
查看次数

VisualState Setter中的UWP绑定

实际上是否可以在VisualState中使用带有Setters Value属性的绑定,因为当我尝试使用x时:绑定页面的初始视图不使用绑定和绑定页面不会使用它们或者我是否需要做些额外的事情?

例如,如果我使用下面的布局并且我启动宽度在400-800之间的应用程序,则PassInput Passwordbox将没有占位符.当我将窗口大小调整为800以上然后返回时,它将最终具有占位符.

例:

<Page
    x:Class="UWP.Learning.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Name="Page">
    <RelativePanel Background="White">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="WindowSizeStates">
                <VisualState x:Name="SmallState">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="400" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="PassInput.PlaceholderText" Value="{x:Bind MyPlaceHolder, Mode=OneWay}" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="WideState">
                    <VisualState.StateTriggers>
                        <AdaptiveTrigger MinWindowWidth="800" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Target="PassInput.PlaceholderText" Value="{x:Null}" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <TextBlock
            Name="PassLabel"
             RelativePanel.AlignTopWithPanel="True"
             RelativePanel.AlignLeftWithPanel="True"
             RelativePanel.AlignRightWithPanel="True"
             Text="Pass input label"
             HorizontalAlignment="Center" />
        <PasswordBox
             Name="PassInput"
             RelativePanel.AlignLeftWithPanel="True"
             RelativePanel.AlignRightWithPanel="True"
             RelativePanel.Below="PassLabel"
             VerticalAlignment="Center"
             Margin="20,0" />
    </RelativePanel>
</Page>
Run Code Online (Sandbox Code Playgroud)

代码背后:

namespace UWP.Learning
{
    using Windows.UI.Xaml.Controls;

    public sealed partial class …
Run Code Online (Sandbox Code Playgroud)

c# uwp

4
推荐指数
1
解决办法
1093
查看次数

标签 统计

android ×1

authentication ×1

c# ×1

client-certificates ×1

json ×1

uwp ×1

wcf ×1