News  [SoftwareSite

Latest News
Older News
RSS Feed
 
Complete Projects
Useful Classes
Top Downloads
Message Board
AllAPI.net
 
Send Comments
Software License
Mentalis.org Buttons
Donate
 
Forums -> Security Library Forum
 
Error on non-Administrator accounts  
by Chris
posted on 2004/08/23

Not sure if this is a problem with the library or not, but when running the webclient sample on WindowsXP with a non-administrator account an error is generated.

The error is:
Exception occurred while sending: Org.Mentalis.Security.SecurityException: An er
ror occurs while communicating with the remote host. ---> System.Security.Crypto
graphy.CryptographicException: Couldn't acquire crypto service provider context.

at Org.Mentalis.Security.Cryptography.CAPIProvider.CreateInternalHandle(Int32
& handle, String container)
at Org.Mentalis.Security.Cryptography.CAPIProvider.get_Handle()
at Org.Mentalis.Security.Certificates.Certificate.get_PublicKey()
at Org.Mentalis.Security.Ssl.Shared.ClientHandshakeLayer.ProcessServerHelloDo
ne(HandshakeMessage message)
at Org.Mentalis.Security.Ssl.Shared.ClientHandshakeLayer.ProcessMessage(Hands
hakeMessage message)
at Org.Mentalis.Security.Ssl.Shared.HandshakeLayer.ProcessMessages(RecordMess
age message)
at Org.Mentalis.Security.Ssl.Shared.RecordLayer.ProcessBytes(Byte[] buffer, I
nt32 offset, Int32 size)
at Org.Mentalis.Security.Ssl.Shared.CompatibilityLayer.ProcessServerHello(Byt
e[] bytes, Int32 offset, Int32 size)
at Org.Mentalis.Security.Ssl.Shared.CompatibilityLayer.ProcessHello(Byte[] by
tes, Int32 offset, Int32 size)
at Org.Mentalis.Security.Ssl.Shared.SocketController.OnReceive(IAsyncResult a
r)
--- End of inner exception stack trace ---
at Org.Mentalis.Security.Ssl.SecureSocket.EndSend(IAsyncResult asyncResult)
at Org.Mentalis.Security.Ssl.SecureSocket.Send(Byte[] buffer, Int32 offset, I
nt32 size, SocketFlags socketFlags)
at WebClient.DownloadFile(Url url, SecureProtocol sp)

I have traced the error to the CreateInternalHandle function in CryptographyStructures.cs and occurs because of the security assigned to the default store (SecurityConstants.KEY_CONTAINER defaults to null). To get around the problem I changed KEY_CONTAINER to "Container" (I assume anything works).

Is this a valid work-around ?

Thanks,
Chris

by Marcos [joaquin dot marcos dot nunezcortes at citigroup dot com]
posted on 2005/08/08

Hi, i've had the same problem.

Apparently it's caused because the library is trying to read the server's public key into the machine keystore, and if your privileges are restricted, you won't be able to modify this keystore.

The solution that i've found is to read this key into the default container instead of the machine keystore. In order to do this, in the Certificate class, in the get_PublicKey method, replace this line:

cp.Flags = CspProviderFlags.UseMachineKeyStore;

by this other one:

cp.Flags = CspProviderFlags.UseDefaultKeyContainer;

Hope this helps,

Marcos Nuņez Cortes,
Buenos Aires,
Argentina.

 

Copyright © 2002-2007, The Mentalis.org Team. All rights reserved.
This site is located at http://www.mentalis.org/
Send comments to the webmaster.