我正在使用Exchang Web Services 2010尝试从邮箱中读取所有未读电子邮件,然后将其标记为已读.
我基于这个例子:
http://msdn.microsoft.com/en-us/library/exchange/aa563373(v=exchg.140).aspx
并想出了这个来查找所有未读的电子邮件,并阅读正文内容:
//Set up the connection to exchange service
ExchangeServiceBinding exchangeService = new ExchangeServiceBinding();
exchangeService.Credentials = new NetworkCredential("userid", "password", "domain");
exchangeService.Url = "https://exchangeserver/ews/exchange.asmx";
//REturn all properties
FindItemType findType = new FindItemType();
findType.Traversal = ItemQueryTraversalType.Shallow;
findType.ItemShape = new ItemResponseShapeType();
findType.ItemShape.BaseShape = DefaultShapeNamesType.AllProperties;
//Only search the inbox
DistinguishedFolderIdType[] foldersToSearch = new DistinguishedFolderIdType[1];
foldersToSearch[0] = new DistinguishedFolderIdType();
foldersToSearch[0].Id = DistinguishedFolderIdNameType.inbox;
findType.ParentFolderIds = foldersToSearch;
//Only unread emails
RestrictionType restriction = new RestrictionType();
IsEqualToType isEqualTo = new IsEqualToType();
PathToUnindexedFieldType pathToFieldType …Run Code Online (Sandbox Code Playgroud) 我正在尝试将签名时间属性添加到我使用SignedCMS签名的文件中.
private byte[] signFile(byte[] fileContent, X509Certificate2 verificationCert)
{
ContentInfo contentInfo = new ContentInfo(fileContent);
SignedCms signedCMS = new SignedCms(contentInfo);
CmsSigner cmsSigner = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, verificationCert);
Oid signedDate = new Oid("1.2.840.113549.1.9.5"); //oid for PKCS #9 signing time
signedDate.Value = DateTime.Now.ToString();
CryptographicAttributeObject cryptoAtty = new CryptographicAttributeObject(signedDate);
cmsSigner.SignedAttributes.Add(cryptoAtty);
signedCMS.ComputeSignature(cmsSigner, false);
byte[] encoded = signedCMS.Encode();
return encoded;
}
Run Code Online (Sandbox Code Playgroud)
在Encode上抛出错误:
CryptographicException: The object identifier is poorly formatted.
Run Code Online (Sandbox Code Playgroud)
有关如何正确添加签名时间的任何想法?我想我可能必须将签名时间转换为ASN.1编码对象并将其添加到cryptoAtty值.如何将日期/时间转换为ASN.1编码对象?
我正在开发一个加密ASP.Net Web服务器的配置文件设置的应用程序.我正在实现的加密方法是使用AES和RSA封装数据.我正在生成一个AES密钥,使用该AES密钥加密我的数据,然后使用我的Windows证书存储区中的证书中的公钥加密AES密钥.然后,我将数据与加密的AES密钥以及用于加密它的证书序列号一起保存回配置文件.
当我想访问此数据时,我读取用于加密AES密钥的证书的序列号,从该证书中提取私钥,并解密AES密钥,然后使用该密钥解密数据.这是我不确定我的安全水平的地方.
为了访问与证书关联的私钥,我必须将私钥标记为可导出,并在用户访问私钥的情况下运行我的应用程序.由于这是一个ASP.Net服务器,该用户是"网络服务".我相信你能明白为什么这会是一个安全问题.基本上如果有人通过网络闯入我的ASP.Net服务器,也许通过某种注入,他们可以访问该私钥,不是吗?
有没有人对如何让我的模型更安全有任何建议?
解密功能:
//need an rsa crytpo provider to decrypt the aes key with the private key associated with the certificate
using (RSACryptoServiceProvider rsaCSP = (RSACryptoServiceProvider) decryptionCertificate.PrivateKey)
{
//decrypt the aes key with the cert's private key
byte[] aesKey = rsaCSP.Decrypt(encryptedAESKey, false);
//decrypt data using the decrypted aes key and the IV passed in
decryptedData = decryptWithAes(encryptedData, aesKey, aesIV);
}
Run Code Online (Sandbox Code Playgroud)
谢谢.
有谁知道是否可以加载KeyStore,以便它只提示给定别名的密码?
例:
在我的密钥库中,我有两个私钥:Alice的加密证书和Bob的加密证书.
当我加载我的密钥库时:
keyStore = KeyStore.getInstance("Windows-MY", "SunMSCAPI");
keyStore.load(null);
Run Code Online (Sandbox Code Playgroud)
我被提示输入Alice和Bob的密钥存储密码.一旦输入,我就可以getKey("Alice's Encryption Certificate", null);用来检索Alice的私钥.我的密钥受Entrust的安全提供程序保护,它是在加载密钥存储区时提示我输入密码的人.如果我没有输入Bob的密码并尝试获取他的密钥,它将返回null,这很好,但我想避免密码提示.
是否有可能在加载密钥存储区之前以某种方式指定我只想要Alice的密钥,这样我就不会被提示输入Bob的密码了?
谢谢.
是否可以从Java Servlet访问存储在本地计算机存储(而不是当前用户)中的证书?我尝试使用MSCAPI提供程序打开"Windows-MY"和"Windows-ROOT"存储,但都不包含本地计算机存储中的证书.
我有一个Java程序对本机库("mylib.so")进行一些JNI调用.每当我想从命令行运行这个程序时,我必须将java.library.path设置为我的库的位置:
java -Djava.library.path=/var/natives/ -classpath MyPackage.jar MyPackage.MyClass arg1 arg2
Run Code Online (Sandbox Code Playgroud)
我想知道是否有任何替代方案,所以每次运行程序时我都不必使用-D选项进行设置.
我已经尝试添加/var/natives/到我的$ PATH变量,但它仍然抱怨如果我没有使用-D显式设置它就找不到库.
我还有其他选择吗?
我需要显示有关序列号的 SSL 证书信息。当我使用
$cert = file_get_contents('mycert.crt');
$data=openssl_x509_parse($cert,true);
$data['serialNumber']
Run Code Online (Sandbox Code Playgroud)
我收到类似 -5573199485241205751 但是当我运行命令 openssl x509 -in 'mycert.crt' -noout -serial 我收到 serial=B2A80498A3CEDC09 是否可以在 PHP 中接收?谢谢。
我有一个 PKCS #7、已签名的 .p7b 文件,其中包含 X509 SSL 证书以及用于签名的中间 CA 证书和根 CA 证书。我需要使用 C# 解析 .p7b 文件,提取 SSL 证书,并从中提取一些值(到期日期、DN 等)。
我尝试将其作为 X509 证书读取,如下所示:
//certContent is a byte array with the p7b file contents
X509Certificate2 cert = new X509Certificate2(certContent);
Run Code Online (Sandbox Code Playgroud)
这对于常规 .cer 证书可以正常工作,但CryptographicException在与 .p7b 证书一起使用时会抛出异常。这是因为 .p7b 包含整个证书链。
我还尝试将其解析为SignedCms对象,然后迭代证书链并提取我的 SSL 证书:
SignedCms certContainer = new SignedCms();
certContainer.Decode(certContent);
foreach(X509Certificate2 cert in certConatiner.Certificates)
{
...
}
Run Code Online (Sandbox Code Playgroud)
Decode然而,这会引发一个异常ASN1 bad tag value met。经过一番搜索,我相信这是因为我没有用于创建证书和/或签署证书的私钥。
有谁知道如何使用 C# 解析这个 .p7b 证书链?
我是否可以在没有类型的情况下声明变量,然后根据某些条件指定类型?例如,我想根据用户想要使用的大小创建一个SHA Hash对象:
//get the Sha hasher
var shaHash;
switch (this.HASH_ALGORITHM)
{
case HashAlgorithm.SHA256: //HashAlgorithm is an enum.
shaHash = SHA256.Create();
break;
case HashAlgorithm.SHA384:
shaHash = SHA384.Create();
break;
case HashAlgorithm.SHA512:
shaHash = SHA512.Create();
break;
}
//... do hashing
Run Code Online (Sandbox Code Playgroud)
这可能吗?
我正在尝试动态地创建节点之间的关系.我遇到的问题是我无法使用变量来指定关系类型.
例如,我有数据:
{
nodes: [
{
"name":"Node1"
},
...
],
relationships: [
{
"sourceNode": "Node1",
"destinationNode": "Node2",
"relationshipType": "FRIEND"
},
...
]
}
Run Code Online (Sandbox Code Playgroud)
假设已创建所有节点.
我现在想要在类型的节点之间创建关系relationshipType.
我试着这样做:
WITH {json} AS document
UNWIND document.relationships AS relationship
MATCH (pdt:Node {name: relationship.sourceNode})
MATCH (cdt:Node {name: relationship.destinationNode})
CREATE (pdt)-[r:relationship.relationshipType]->(cdt)
RETURN pdt.name,type(r),cdt.name
Run Code Online (Sandbox Code Playgroud)
然而它很糟糕,[r:relationship.relationshipType]因为它期待一个明确的类型[r:CHILD].
是否可以使用变量来设置关系类型?