Permition certificate private key from webservice

Discussion in 'ASP .Net Web Services' started by Waldek, Nov 13, 2004.

  1. Waldek

    Waldek Guest

    Anybody knows how access private key X509Certificate from CertificateStore
    (Microsoft.Web.Services2.Security.X509.X509CertificateStore namespace) to
    encrypt/decrypt data.

    Below code in webservice return error: "Keyset does not exist" (at line
    includes ct.Key) ,but in desktop application is ok.
    Probably problem concern security context, but how set trust for this code ?

    code:


    store =

    Microsoft.Web.Services2.Security.X509.X509CertificateStore.LocalMachineStore
    (Microsoft.Web.Services2.Security.X509.X509CertificateStore.MyStore)

    'Open store
    If store.OpenRead() Then
    'Find some certificate
    cc = store.FindCertificateBySubjectString("My Name")
    If cc.Count > 0 Then
    ct = cc.Item(0)
    'Set private key to RSA object
    Dim rsar As System.Security.Cryptography.RSA = ct.Key
    rsa1 = CType(rsar,
    Microsoft.Web.Services2.Security.Cryptography.RSACryptoServiceProvider)
    rsa1.Encrypt ...
    rsa1.Decrypt ...
    end if
    end if
    Waldek, Nov 13, 2004
    #1
    1. Advertising

  2. Waldek

    Dan Rogers Guest

    Hi,

    You may want ot make sure that you have considered the configuration
    information required on the callers side?

    There is some good background information here:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/ht
    ml/THCMCh12.asp

    I hope it helps

    Dan Rogers
    Microsoft Corporation
    --------------------
    >From: "Waldek" <>
    >Subject: Permition certificate private key from webservice
    >Date: Sat, 13 Nov 2004 19:09:26 +0100
    >Lines: 37
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
    >Message-ID: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    >NNTP-Posting-Host: e.telsten.com 195.85.209.206
    >Path:

    cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10
    phx.gbl
    >Xref: cpmsftngxa10.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webservices:26519
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    >Anybody knows how access private key X509Certificate from CertificateStore
    >(Microsoft.Web.Services2.Security.X509.X509CertificateStore namespace) to
    >encrypt/decrypt data.
    >
    >Below code in webservice return error: "Keyset does not exist" (at line
    >includes ct.Key) ,but in desktop application is ok.
    >Probably problem concern security context, but how set trust for this code

    ?
    >
    >code:
    >
    >
    >store =
    >
    >Microsoft.Web.Services2.Security.X509.X509CertificateStore.LocalMachineStor

    e
    >

    (Microsoft.Web.Services2.Security.X509.X509CertificateStore.MyStore)
    >
    >'Open store
    >If store.OpenRead() Then
    > 'Find some certificate
    > cc = store.FindCertificateBySubjectString("My Name")
    > If cc.Count > 0 Then
    > ct = cc.Item(0)
    > 'Set private key to RSA object
    > Dim rsar As System.Security.Cryptography.RSA = ct.Key
    > rsa1 = CType(rsar,
    >Microsoft.Web.Services2.Security.Cryptography.RSACryptoServiceProvider)
    > rsa1.Encrypt ...
    > rsa1.Decrypt ...
    > end if
    >end if
    >
    >
    >
    >
    >
    >
    >
    >
    Dan Rogers, Nov 19, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page