小编Viv*_*wal的帖子

如何从X509Store加载受密码保护的证书?

我正在构建一个受ACS保护的Azure WCF服务,该服务要求客户​​端通过证书进行身份验证.

我希望客户端(和服务器)从X509Store而不是从文件系统加载他们各自的密码证书.

我正在使用此代码:

private static X509Certificate2 GetCertificate(string thumbprint)
{
    var certStore = new X509Store(StoreName.My, StoreLocation.LocalMachine);
    certStore.Open(OpenFlags.ReadOnly);

    X509Certificate2Collection certCollection = certStore.Certificates.Find(
        X509FindType.FindByThumbprint,
        thumbprint, false);

    certStore.Close();

    if (certCollection.Count == 0)
    {
        throw new System.Security.SecurityException(string.Format(CultureInfo.InvariantCulture, "No certificate was found for thumbprint {0}", thumbprint));
    }

    return certCollection[0]; 
}
Run Code Online (Sandbox Code Playgroud)

问题是,它没有加载验证所需的私钥.我试图将return语句修改为:

return new X509Certificate2(certCollection[0].Export(X509ContentType.Pfx, "password"));
Run Code Online (Sandbox Code Playgroud)

但是,这会因CryptographicException"Spcecified网络密码不正确"而失败.

编辑: 如果您没有传递密码参数,.Export()方法可以正常工作.

对此有何帮助?

.net c# pfx x509certificate2

21
推荐指数
1
解决办法
9255
查看次数

ActionBar MenuItem Divider

有没有办法在ActionBar for HoneyComb +的菜单项之间显示Divider.

有些帖子说只有当菜单项有android:showAsAction ="withText"时才会显示分隔符.

我想只显示Icon而不是Text.

我通过实现Action Bar兼容性成功地展示了Divider for Pre-HoneyComb.

我不想使用ActionBarSherlock,因为在这篇文章中给出了Android操作栏sherlok没有显示divider,因为它是时候在我的所有项目中从Action Bar Compatibility更改为ActionBarSherlock.

当我看到Android Source时,我发现Divider只有当它有如下所示的文本时才显示(来自ActionMenuItemView)

public boolean needsDividerBefore() {
    return hasText() && mItemData.getIcon() == null;
}

public boolean needsDividerAfter() {
    return hasText();
}
Run Code Online (Sandbox Code Playgroud)

有没有办法可以为ActionBar提供ActionMenuItemView的实现,其中needsDividerBefore()总是给出true

android android-actionbar

14
推荐指数
2
解决办法
4万
查看次数

当SD卡卸载android时获得广播接收

当媒体卸载时,即在卸载媒体之前,我需要获得广播接收.

这样我就可以在卸载Media之前将文件保存在SD卡中.

我使用了android.intent.action.MEDIA_UNMOUNTED.

        <intent-filter>
            <action android:name="android.intent.action.MEDIA_UNMOUNTED" />
            <data android:scheme="file" />
            <category android:name="android.intent.category.HOME" />
        </intent-filter>
Run Code Online (Sandbox Code Playgroud)

但它是在媒体卸载后收到的,然后我无法保存文件.

我还尝试了MEDIA_EJECT,MEDIA_SHARED,所有这些都是在Media is Unmounted之后收到的.

有没有其他方法来保存文件.我不想使用Thread来保存文件.

android android-intent

6
推荐指数
1
解决办法
2350
查看次数

一次启动多个Android模拟器

将ADT/Tools更新为20后,我无法一次启动两个仿真器.

它工作了一次.但我不记得那次我做了什么.

我试过几次重启我的系统.

我不知道如何找到模拟器中的问题.

模拟器显示在TaskManager进程中但不在屏幕上.

编辑:

报告为错误http://code.google.com/p/android/issues/detail?id=34221&sort=-id&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

android android-emulator

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

Android JellyBean BigTextStyle通知无法正常工作 - HTC One X AT&T

我已经实现了一个BigTextStyle/InboxStyle通知,但它显示为正常的通知,它显示在我的HTC One X AT&T(4.1.1)上的JellyBean(在Gingerbread,ICS等中)之前.甚至动作按钮也未显示.

我用模拟器检查我的代码(使用JellyBean 4.2),这是有效的.

看起来我的HTC One X版本没有实现JellyBean的新Notification System.

HTC One X AT&T设备信息

Android Version - 4.1.1 
HTC Sense Version - 4+ 
Software number - 3.18.502.6 710RD 
HTC SDK API Level - 4.63 
HTC Extension version - HTCExtension_Sesnse45_2
Run Code Online (Sandbox Code Playgroud)

源代码

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private void showNotificationJB(Reminder reminder, Intent intent) {

    Log.v(TAG, "Showing BigText Notification");

    Notification.Builder builder = new Notification.Builder(this);
    builder.setContentTitle("Ezeetrak Scheduler");

    AdditionalDataStore store = reminder.getStore(); 

    String passedBy = store.optString("passedBy");

    builder.setContentText("Recieved an Event by " + passedBy);
    builder.setTicker("Recieved an Event by " + …
Run Code Online (Sandbox Code Playgroud)

android android-notifications android-notification-bar

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