c# - Mimekit causing bad data when decrypting an email -
i have email application creates encrypted emails. works fine in outlook , email counterparties send email reports no issues. when try decrypt them mimekit "bad data" exception.
some of stack trace:
at system.security.cryptography.pkcs.envelopedcms.decryptcontent(recipientinfocollection recipientinfos, x509certificate2collection extrastore) @ system.security.cryptography.pkcs.envelopedcms.decrypt() @ mimekit.cryptography.windowssecure...
my email mime looks this:
received: dx ([x]) x ([x]) mapi id x; fri, 7 mar 2014 14:48:49 +0100 from: x <x@x.com> to: x <x2@x.com> subject: xxxxxxxx 07-03-2014 14:48:46 thread-topic: xxxxxxx 07-03-2014 14:48:46 thread-index: aqhpogv3jhiue6wujk+equ4eaa1oda== date: fri, 7 mar 2014 14:48:48 +0100 message-id: <x> accept-language: da-dk, en-us content-language: en-us x-ms-exchange-organization-authas: x x-ms-exchange-organization-authmechanism: x x-ms-exchange-organization-authsource: x x-ms-has-attach: yes x-ms-exchange-organization-scl: -1 x-ms-tnef-correlator: content-type: application/pkcs7-mime; name="smime.p7m"; smime-type=enveloped-data content-disposition: attachment; filename="smime.p7m" content-transfer-encoding: base64 mime-version: 1.0 miieogyjkozihvcnaqcdoiiekzcchiccaqaxgglnmiic4wibadcbyjcbxdefmb0ga1uechmwrgfu c2tlienvbw1vzgl0awvzieevuzeambgga1uecxmrqnvzaw5lc3mgu29mdhdhcmuxntazbgkqhkig 9w0bcqewjmj1c2luzxnzy2xlyxjpbmdazgfuc2tly29tbw9kaxrpzxmuy29tmq8wdqydvqqhewzb yxjodxmxedaobgnvbagtb0rlbm1hcmsxczajbgnvbaytakrlmr4whaydvqqdexvkyw5za2vjb21t b2rpdgllcy5jb20caqewdqyjkozihvcnaqebbqaeggiavuegp1iwgqbtvu6w6biukhmcjcrhotqp tuzsd/zmfyi95y/8cxsyf3ivd6aelld+cn9cyvtntp6upznameta8qwd2gbcprmdnzpcapuc8hwc +nwaa1un2kjxrf/ecsl+94g/fixbz5/53o8kl5rhgkt0aotwv1ly8vnwsazt+qmxkr70owrwy4tl vmpsblcehz5vim3hfw1huz7xj/i5e1uklyzdf54oiesr2mainifgzcp3gr5eup5+iyuaa8atckjp ewsq6kk2kgsjhcwf2pdffmjsrloybloavsbbebmftfsu4/hpyevdtpyecogdvtbupgmdzlkbqrf+ zdeidphzfj1cvpzbldy4t/4g8uiwykybun/yridlbouguohucs36xzrxnbxvovep833kuhi1mdew hcvypraf4ndtseqpvx4wj0mbiregwui79iii8jpr5h75fvbvxs5acjrtykq5snwo/hubhfelxk1w aypqa0qwjyiozkbluhswmxqxn12vwh5urxyndst8f2j77t086rx8aemsoh+dsc3dspqwc1xtub34 9ag05w0qtlzcmhkt4523ltc339f3boza2hcnzsohi0ihj1vg422i0mswvlpu9lid0abqcoiy491c 4br4uqaheqxk+hl4he05pjr+wgkpu0jfoeflfgrw6sywghs1bgkqhkig9w0bbwewfayikozihvcn awcecdsbig3hg45pgiibejgys8bl0sdaj9rkjuepnjqgtgevf3xdazwbnhkmfgg35jr1rporngaj q0tsk7hwhzamwnlwbyherxupw79fo3e49r2tzqnza25zui+pviegpv99iydesg/on/xdgw25o5v1 kkyemgqlu/j8cbso2crv8u6yiyvqkvauq+skpymbq+ck+iims09apz5izo56fx2gozhybvih9r7x j1foz3rjo5crymzcpiwykcnp5kfvtww8j2dmwhfknhmrp8ecgillpaegay7wjvwhokzxhwf2ptlg w85zyucmc5j1b1dfdwu7s6okhrcjktw56s/sskx7tu4brf7x0tujk4wgbphxxhqccc9de55qha9j qslyusogbh7s5gkawqotapi1eup67supr2oxwscahgofkaui1tkqtjleiss+jut3vhoo1/1mtxxt vjjxee7cxqmrbjg08silkwrftvem6yzvjkre0e6qawhtsttmykpihqwvdq0/hi0xnpc+85rdtlg8 zsarzd/lmqvqngxml9ursvl1ovcjn4lsbuf1aig+zswqcf4iaarbozeqfm1qxrancfjyhearfjrs zjcbgbpiav40zkb+fikdhxg2wrv+rmguo8m+u9coyhuvk7jinqdvdkkzempj+1klwelzfp3bivqm pkja2be57bfoevduyw8s2feefhdumrmobvtcmapciuhaj/euxojus55kdh9d3gp+kt638zszvuj1 wbqnoowp0crwjzbwuii1iim/s3xnf890akmg47g3dytkntevkuqwqfxitwbrmp4ishmoihykgega k16v4jtfrqtluokp52cmb6u5f1wnpuueiu+ibvqx8u8yam8emihe6fumdirkgqtp+llw0w1ftsnn lrpwfktm7g0ydzpqokdstkqbhfqc4w2ffzxr16rd7c0qgbprsfuiyqkkvml5lziq8f7myguyijch jpqqyq8hkvusgy/3maqkjc1wf4wwmit5a1/sdzcrobs3u+asnpdhg43fuxrfhglg4h/z3++q+hxz l0nupn77f9fhvwcyyxwhw6pcpbtmbds7z5tq6si+hlrnjblbpqcytgrv2en77irp40o2kqag/nbd yzgmjw37/3p+2ibgeu8pfzgdi5ohmdj59ztctw+fwc0uhldjzb/nnqjhx6hgxqegaddlmdrh9bco 0yyxc2xx5r4go2bnqye+dler8zljbhzymk3d+z1y4sdide6wyl7+ef3frg+g3bq31jvdckug3n1p uw0i8buzvffuacrodizrcrsxxl+b3qlpkzh0i5yryrcivdhab57+tahh3kbghu1ojibl1hxwxdbt cad9itygktxjklglsg8xxg3l/ckgnh+yo712jphityer/mhm22rx1iht/n1qkjbw1inbo58f1uzk xyx3h28r0wom1keluob9ecf5jt/ffqkoi5hwhhptzd//xvqc7za4qxccr0fmgwbt8xjqxh/ftrwa 1obpmdy4nli8p3kodzefjz0sb9srtojimdf/4xep2+tyblkibrinx1uokn/gc0gfrapocd6kft+r zmlbtkxlejnkvn7cmrvyl05e5ws2ktb20kfhjmdtozxuvmqdjb797sufcnzj45xsoadwjtx/yfgn 1iztlz6oghz5vktitdmniwkq3fs48ljxqn6/kjwv8vvzwtwfb73gqsiudf/j6p1qdtkkjd+talrq npa86veln7yc1xgzp7rbi2anqjyavzwkleztanxjmr9b5htqqpntwggkzwtuvptsbs5syvsnkzau ueusmioyhzel+h1hrzcsg67v6rcttad74wao62pihsnes7yp1brvtsqjqj9vj1jh1kjzfe9o9yqk 2pbqc1gdtll3ttbewne0gt4lj6j5rsslsjibcchfjwzipynrghmpsurg9z4/yjzlgwej8qahbi3p egpmawc0fwi8mahwtkemmlexdefkrhpk4v8y4fq8cslpi5xfhnbcjx+ge8zjjzo/hbjirddrflgi dpfsaq1v0dqbcrv4sq8le4gkthnucmqokogfhyqv8sltssdbdb0pjyd/arh7+rotteii5g3ykolj jwlsqtavajnq4gzeggxvz337ez+quj+oost9bt6avqmz0hh7lr1nremg/2ujxtipmu5vqg2/59r+ jmy3gowyjs/r3ya2py31otfprtpnupvlq+8kjx82e5sqrbj9oee129o7aist9gxayvyhoprbr3hv uz2znoxudksbziy5rbf93forgqvfn1474nvqct8ovrjhkyzbwsq95fsv5a2khyz/l4wvujxiqoaf w4z+crljbgkuzkwtgrv79r/3j4mipuixcm9goj8qcq+rfnodoum6dau/azpxmd1cqvkiteffoqx3 jvzbcqy9q3vmez/6/aeg5cbv3dzkowrgzcbvi/xcpytqmbn2ssumrakfw1vjsvzk5sdkkn5ayofj xx7rbldvyjye7mzbgpbvreprb30bw6gf5hhtkkw1zrhflnp65laizhysyaekknmrsaqcx0o5lfwh 8paullnvqr0jlpcstarg7fldfstl+u0/t+otm9reqkdrfpnp2do8b7m6zglo/mjejntta4gpcy/4 c3qi5dn5cw9rsa6f4t6v865+fblyu8+ibdoifwmm/l+qd6v9fhiizfdpx0wwk9zgthfwsvzobfgy 5eq5ze1ner5op3ef4qzseq3xrhs8gvdcss6/xtgploer+8tw2d86qtqkcspvfixz+g+mjcko7xzk rddenv3aagxjhmare45r/e+hyum0weuy1uyeoikkfdfsn7eak2ftkba5nseoshvchrvdiwk2q/ym doh5kizuu2hpviy34w5jnvieqwnra8yxarzyhc4a4bbcmywxddzwwwsvoxdqoiynf71xxccue1e8 bznirxq0zhc173bgoskszawddee0c7cyb3w0q7wqfiw7vhrbvtztnc5kapx7eyjomblm+fb39qg3 ycdjpxkkezalpmtaylzt8rjiu7ldj4ds2/ouw4nyphlgycj2qtflpmcpvu/b3pkeamptww/iq9dc fm8sfdldfyapuuvteogrirqtm4otmittrqovgh9hij4ojknbtmv6xatr3fnd6i1henc4racy0qn+ m7rnlhexaebmf1wi3rr+o5di54sd2tmwlxq82gttxt6rqo6kpcrssbtgbaouz67t8ltruk+wvpop xmanyfrr93m7gbdeeku0tr1huuatd5nwwffjvlzo2ohbuxuzzyqj+tiudvvcrot+tuwl6xxu/cgv lt8lanx17orpunjrtkrzgrfd/+hahbi/dnb4wcsleijziybh9rcjqeuzmeknpbr9b/60ettnpogz fj9any9zag8vjl9ljw73lmzrabxu0+sb2ksczysfa+nabwrri0gxf7d0nmybfoeo+v5qy4zoce+2 af3o9wapqnw+iswredfxnaham+lh3o9xapmqhdtupqqwoen+oj4q+k4z7wa/k62urmbjkhmyoa+4 z5yiecuzivhnoogaa65b7ktu6zbikiine3jfflcrqon1rehwjhdna4vt344mh/ljvahl4khnrixo dhe/8bahriifrdwhdwlpr2dovuoy/fc/oe7bo4byih629bxixqcx0d/wr2/ajqjwh6gewy0fhwyg mjzumkdsaibp8ufvomckg89egzv0tnpckn9hi7z03umk9pahie6lw4mr+w3bovtzdze5xrctbgvz fxyz7ep/8tlshfxpjczaeg1ji2a1ou4rcexp3yb20u2z7hnvqoobfliwruaialaw1ufp8eb4gcrt 5qisdfqf64dly90cjqg0yfwvbt0xqd2jm98zoypu/sfudxyt/xq6peslchprs3dxrkiipmsd/etb 68lluh8gociheicx5uusvknhtxldqewnybmodoxue3epawbs1uyrt9qgw6eqz/1cz4msbbkcph13 qu9kqjdnike5qzbwxgz8s/hv72i2jaq1/e9xvalkatjutqeztoaaf+luv021c74qgjveprdnl68t 31aqyp0n8u2ooefq1mwr/w+rhmemvvgtsn5j3p20vtcshl+di7kgkovuxol+m2fiye6tszm0ykgk oze6eoecxlblwdj2s28rjg8kzcqn0vtgl3uc5pndkz4chwbpbxoxo5bskwifpqir9lp2bssqlumc 1eor9v2qrasnpc/j+vi+wi4gz+3niib7zwtgetd+0auqkrhebbmr86zmghykbrdtfj63xjhsox9k mbzg7yhdeyxtk5blwu+mhln3gtsculxyse/ie3zvnthtsn8m99wblpr4exq/ehg1e7umpkhh7mnn 5zrzxdhzgb++k/nqttllpjcn0oqiebypmwnnnr6+7xjahdk+vvplqc4epb3k4nttlc6glzsplbn5 3tavfzuu9ep66jhiqog131v3t5cwxxgokmgns21cqf6pbnm0wp+jx7dlemeoqsjpbsorjkriruzy j8o1s+dg2v2cvsfdsh08pvqsjymrrtpyadpmmfckjzbmjakjfvgqznjaeyqmak3jfk3jtco5/gvh yp/e3htgh+3wyhzqhdqnxagycv726twdelczhd4bp/k6k4c2igq2op7cp6lejcwsqdp5vgp24vh0 odeuwgfm3xuhx7pdtkhxfhkfbomsql7+og2xfoyb6sxnbnn2obuujjxnikgglgawrhg2do2fwnyn teht1duopowkkqdnhrvqsjak5eiqv7pk3zxnzbhhsxz3nyqiowcdpe65kbohmskijcoowpgixtb0 utjwrrlcaln2cktpad7k4ynzdokqaazhrxcpzmclfebev4w8t2b8wuh2gsuwlbtlidsixp2pom0t at7zo5/mncdtfrg4ncau+j5pujhwkizogyu3da6avfjlseqnd1up3zdw1zwybvbegufzswvqxboz jmhf4jdzas3dty/rkakyhldqc7usxiclm1p++jleuw4j2veo0ojwjwme04utieof4m7kvyvsi9qt vhqgnxmlrxqdgzanpoz9rock+5ikqs4zzvh1hfxbtvtyp4wkihv5rvisrsli9z0x7jbgy8pt8fb4 vneorpbevjftej59blydze4yhzg5+ug44mq77mrdkbx3rr0ms3ny5izvmu7pqw/cfeg8x+zlrlzx dt607gtaf9un+/zwpw77mhr4kqptlfhyen2qxld0dxztjn3ybonriytyvbptyncaqgw424tawcah glqmqp3rzkpnoztc3d7picxuosfpjcmgjwlklnetzhwtfyipv8hv9hjve5khunlxlatez/krq0td 19edpjh9hbzxmvkhmvm1msblf1fko/o0nz8deh+o0ux8w2g+r88rf1y/g0gc/j60r1tutm7kzjuq wn5lt4me6fvsa8p8zlfgbu9z0hm0u8rjlos1vvm5itdz6uxq4e5ll8nonng5wd3vf4pvrtnzcwo5 1bqhnu+3z7jegqls+ahy3e3paibkxk5bhf1d688vm4vy095p4cqoo7mqji4xcc5miy3wv0sb/zqt lbyf0p+ibdn6shwhvlppqcttaeaedtymquecwynvxeux8vhep+9tgpiz3fu7b9eqru/8fclpfidq w62644vajstlih5/pekdohtdouyr17uksm1s2af/r6woq58tkmnyorelxp1yiis5ktk3/23tt2ws dsfbkvwqdv7c6xqp406wgk4i8gcwuxnwn203v9tdnpq/tj5g6bnzs0jsouv/jndpotlmdq5l91f3 xqfzr9nzruo8cnliv6az4kpblbg3xnncl6nnvt4fqaar3ktld7odjkcace/ood7qfklkrtdtlsjw tthvuvsxcouisd8j/4abfq/fpig1ds44kctvisg3zuia4yjcweo/qn8wxpe+bikgrpf+d45qistv jhzixkruw9xclvlqsw+8umbg/slzxun5aqz4awy20o9j6i2cqp6qesbrw4lgag46fv+u3xfr5asc dtrgyabhllfjmjfkbns9oyqmp6yle9kyosau1mmil7a1tssaeyipobzzuwq43xqyyhrurranafb6 kfygwavpz98sejod9ylqguupnlahsnxdiatpjjg8bkvuz5nohfp0me5jawio18mbnenbe/iafjsx p8myd0bvsys1g7ycyavu1bmdl8r9fs85i3aotsr2b923blvoi86gjd5sjdytbdrmotcebcyq2xes pjhgbiijtcm7+qhyzyeeg13qih9x5sskuysu2z9c35l3umycart2fbpfu3l6ebf4m1ehe35a/u8n 416sd8afptuv716g4winlq6f9lug8i5zls2n5fegeaf7f8xb9ecyvpejrhup7md2jdiuauxzbcmz w1uk/nvbesxcrckagzko//hw3flqggj1viebsn6wgrwr36bveljcaydvwd682cixsnbwp2kknwnd ybbty2hs7sclnwvd9cxsn57uzavhrfzji86w4eovpk/qgyz5kmsrgp26ahceckb7kqz+ewy9goui naegl8+bdhk8jp59s8ooqtmq3/9qnw1ecxq+cx0w9hlyezq4mbq/vmr9q61ps4dhomd78rrwvnai qxhyi5gsk83e7xhrlemr3kwwo2iv6qmot2yaz5x6xuq1x0veh+coxiypynr7q7b0wngvetit9tt2 rgnj3zcormvrboumrcbpuyj1nqateaikjtmmjhmndyvagplv6amjmhawlxaattvnrk2oomj/oomd ajgvwxuklvdfjmy9fw98fmbwkshrp6rshdgi7ps7agrfhwqqykyalzo73te7xo8wie71hmvkij6z oholmbeptupngdwoa2pdadvpfqe71tebzox8me0kvktf0tpklnww3hamlmpmnjtuewft1qpg8qoz anzxwwkbhj16yny1vgrhtarqi0mmw0tua65ddmldjhdes6wbznv2n0qrnmjklrruclnizqdjq+i3 ldhuitodrhuvgclder6b/eeev+lws7ety6hep+ecv9w68wf1h+pjwcmhxqsoxsdz8ppcvg3d6x49 2lwivhdp9c9c73fplvtk8krdbnva81lnpstng9vplsdzza2xzrms1itdw26jdamwqm+i8mwznqtn 8amvg7oxifwogtnlpghzul4wnzjqoggi81ny4demk3pqgw4d9b1bo6wckijacfwh2yhxlixzrmj9 9ruqlamw3gtwtswjsmspdlvetyq17fruc/mw5qjhheg5bntek+6hdith+somqhhiflf4z6cpr22p 7hhzlcrvbovlyxfhncgr1y8fpllpj1f4vacvi1h0bpecngmaud5fea5yxp4b366dkgocvuaud1cu h2zugw7ewgce/0n4hwjkbvjcu07ksdzydzebzgefasstdjm0abim1a2ex0yy8qbp7tzdicugqcbb lpckxebjgt+2fiqg7p0iay7/1+ds0mm0jcdk4cq21z1ejwhefpuzphqy/wy8quwgsup/so4mubza y/mfdjbwydenwjp99gxabpqnd8bao9s+yrkoeziferqk6um8eclbnx1auqwurgeursarsqm+jso7 /lgffurqydwqsdcnv0squumlc3p+wmqr3ugdrp0iyadsow4dnt+4wqtubd3go84jgligafthvqmz q9dc3f3ky+xm1a2mdbme8yg+hpvhmuhvcsgevim9uxah9xljpewo705mliq4vvfh4v3p2d7nyeuq 60quncvgt4zbvvspppkdt30yf3oq/hns0lh4fjoq8wvthdr8dvhnlsym8e9b9h1skudx/xyjziob vltvcdlh3e38twfxj64rf83z2rwsjlmetgk1kpglpr9kfm/p5nvucpxrlwmgjzf/jksmxguklgzv n613kbpdofzhux0eue0gomr3fqu4wisfkazj174rm2mriwsui2agc0pqhtsjzbqpoocqo4g+cr8d dg7whpfh3qxghlq2qxk+ilbxqtlnsvco6bbfoyso/uvvkuf2jyzd4wbmlrdg9i7o3nnnsoebdxa0 yksrqe7uvzqzmrgb2qw+yh8gops5lfwshqh9bn2p/ejvhpiixtnogl4vltl1pzqvhc5g6y1znsw3 +azwi+wilqxb0xxkbo6frxkvzatygobffr7ashucqjwyxr0byq7qchy6zyfbnsm1ggjjmznjit8j nhkrs+r71q6wkvqyw7rtisgcfh/tgwv4moysuwnxho1oja7fxnebymfvgdmnbu4xq+tzqajoip4o ayavoo6aeazht3fms4bpytqmy1x5ipuy1xzetzwjb5yvovmdkcps0prd2ghwq9zoez75xxll6zff 4h1maibctyfxgv2gcojstwzedu4bgihsijrfbocn2j018hk33ac8nza2jw4uge6bw4ijebtdgh5x nlncxydixvz/n4oqefhsnz3fghiqcbgvxj8eg1gql/+2usolgzezy2wwpajphvj/3o0eknhwjpoc x9nhnbmhgyirxkpoghb1ffe1q+s6quq3ghngo2rkszbr7c8nijdfcgui0tpcqgwua+72tytii2ui qxgfjvxgxysan5gfbrrpxrat0yyr5oamuzucmjopkytde/2mjuxaexftklhmgcltulwnoubv5j2b ffdrtijthum8f1laq5k5ehiwvrywjh3zmtbweeceowaiobmnyvtd3xbszx6sh+20t59rdr8p0mjb ecvc0pl3qquge5w0qrp7/cj2pxrmcc7tcwdnvojglp3jcubl2zrjeqbpk5bm6occzr+svifux2me mf/3e7tsrspbpscl9xhhh8ebznnjz8fjau0yahtgjzl1dojjvz9knlxwwgg+mcalm+xu8dpjnkg9 nuq2uysru4p5k4+leayrm2cdiplvcdugkqpbgqnhsb6dsllimiyxszy6ochisuf4kyages5tsbxr i1ifnhcw4g/7i4vuy+530pqa0+tecnkpgigxrevwk0gf0ngd+ddngdzzrjjarpmx0ufbp9twvvv+ 6j/meqkiykycu/nuyv/tunierkroowzs697iyy/g3npwhzurzxjbmk9mpnd2wn5pzzrtx7qybvfn nenl/wtsvmmka4d1dlnhoen1hoayqgrfqs4yyml26uemhcxiv87haywwoabpfr4=
this how perform encryption:
public static string encryptcontent(string content, x509certificate2 certificate) { byte[] contentbytes = encoding.ascii.getbytes(content); var envelopedcms = new envelopedcms(subjectidentifiertype.issuerandserialnumber, new contentinfo(contentbytes)); var recipient = new cmsrecipient(subjectidentifiertype.issuerandserialnumber, certificate); envelopedcms.encrypt(recipient); var encodeddata = envelopedcms.encode(); var encodeddatabase64 = convert.tobase64string(encodeddata, base64formattingoptions.insertlinebreaks); return encodeddatabase64; }
and how attempt decrypt:
var primarysecuremimecontext = createsecuremimecontext(certificateinfo.primarycertificate, certificateinfo.primarypassword); var primarydecryptedentity = entity.decrypt(primarysecuremimecontext); private securemimecontext createsecuremimecontext(string certificatefilename, string certificatepassword) { var securemimecontext = new windowssecuremimecontext(); var certificate = new x509certificate2(certificatefilename, certificatepassword); var bouncyx509certificate = org.bouncycastle.security.dotnetutilities.fromx509certificate(certificate); securemimecontext.import(bouncyx509certificate); return securemimecontext; }
when decrypt content myself using enveloped cms directly, there no issues.
this email after own decryption:
content-type: multipart/mixed; boundary="5511bd79-26dc-41e5-ac96-7adfdea5f6e5" --5511bd79-26dc-41e5-ac96-7adfdea5f6e5 content-type: text/plain; charset="us-ascii" content-transfer-encoding: quoted-printable --5511bd79-26dc-41e5-ac96-7adfdea5f6e5 content-type: application/octet-stream; name="testfile.txt" content-transfer-encoding: base64 content-disposition: attachment; filename="testfile.txt" 77u/vgvlzwvlzxn0 --5511bd79-26dc-41e5-ac96-7adfdea5f6e5--
can see causing this?
after having using dummysecuremimecontext proposed jstedfast works. more thorough walkthrough can found here: https://github.com/jstedfast/mimekit/issues/38
i think problem way adding certificate context:
private securemimecontext createsecuremimecontext(string certificatefilename, string certificatepassword) { var securemimecontext = new windowssecuremimecontext(); var certificate = new x509certificate2(certificatefilename, certificatepassword); var bouncyx509certificate = org.bouncycastle.security.dotnetutilities.fromx509certificate(certificate); securemimecontext.import(bouncyx509certificate); return securemimecontext; }
what doing adding certificate addressbook certificate store, want add in order decrypt (because you'll need private key password well) personal cert store.
try this:
private securemimecontext createsecuremimecontext (string certificatefilename, string certificatepassword) { var securemimecontext = new windowssecuremimecontext (); using (var stream = file.openread (certificatefilename)) securemimecontext.import (stream, certificatepassword); return securemimecontext; }
the exception message getting isn't helpful, guessing means can't find certificate and/or private key. wrote test program , have been unsuccessful in reproducing bug, wrong... since certificates/private keys imported personal cert store, i'm not sure how remove them test theory.
let me know how works out you.
update: oops, done goofed. updated createsecuremimecontext() above open certificate file stream because windowssecuremimecontext.import() takes stream, not file name.
Comments
Post a Comment