For a personal project involving SSL, I wanted to create some certificates that could be used to authenticate the client and server to each other. Nothing fancy - self-signed is perfectly fine in this case since the client would have an actual copy of the server cert to use when validating the server, and having the cert on the filesystem is secure enough for the task. In any case, I was disappointed to find out that even with all of the other crypto and certificate support, .NET lacks support for this. I was also disappointed by how difficult it was to figure out how to do this.
CertCreateSelfSignCertificate sounds promising, but it ends up not being quite enough. It turns out that you have to do the following (as simple as I know how to make it, anyway):
In case anybody is interested, source code is attached and is free for use by anybody as long as you don't hold me or Microsoft liable for it -- I have no idea whether this is actually the right or best way to do this. Give it the X500 distinguished name, validity start and end dates, and an optional password for encrypting the key data, and it will give you the PFX file data. Let me know if you find any bugs or have any suggestions. Read more: Where are we going, and what's with the handbasket?
CertCreateSelfSignCertificate sounds promising, but it ends up not being quite enough. It turns out that you have to do the following (as simple as I know how to make it, anyway):
- CryptAcquireContext(out providerContext, randomContainerName, null, PROV_RSA_FULL, CRYPT_NEWKEYSET)
- CryptGenKey(providerContext, AT_KEYEXCHANGE, CRYPT_EXPORTABLE, out cryptKey)
- CertStrToName(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, name, CERT_X500_NAME_STR, 0, dataBuffer, ref dataLength, 0)
- cert = CreateSelfSignCertificate(providerContext, blob(dataBuffer, dataLength), 0, KeyProviderInfo(randomContainerName, PROV_RSA_FULL, AT_KEYEXCHANGE), 0, startTime, endTime, 0)
- certificateStore = CertOpenStore("Memory", 0, 0, CERT_STORE_CREATE_NEW_FLAG, 0)
- CertAddCertificateContextToStore(certificateStore, cert, CERT_STORE_ADD_NEW, out storeCert)
- CertSetCertificateContextProperty(storeCert, CERT_KEY_PROV_INFO_PROP_ID, 0, KeyProviderInfo(randomContainerName, PROV_RSA_FULL, AT_KEYEXCHANGE))
- PFXExportCertStoreEx(certificateStore, pfxBlob, password, 0, EXPORT_PRIVATE_KEYS)
- Free everything.
In case anybody is interested, source code is attached and is free for use by anybody as long as you don't hold me or Microsoft liable for it -- I have no idea whether this is actually the right or best way to do this. Give it the X500 distinguished name, validity start and end dates, and an optional password for encrypting the key data, and it will give you the PFX file data. Let me know if you find any bugs or have any suggestions. Read more: Where are we going, and what's with the handbasket?
60 comments:
aXbt michael kors sale
vRra plaque ghd pas cher
rEfs north face sale
5dJtt cheap ugg boots uk
0nHah michael kors handbags
iHmw ghd hair straightener australia
qPxt cheap uggs
cSgm michael kors bags
4xAxw cheap ugg boots uk
5iPyh chi hair products
5yFjz ghd straightener
6dJiy nfl football jerseys
2jZpi ghd nz sale
8kNsm cheap north face
4sKzu ugg australia
0bCpi ghd iv styler
5uTck michael kors sale
9jAvr nfl shop canada
3oPhi ghd españa
9oFsn ugg boots sale
http://www.tomnjudy.com/WordPress/wp-content/plugins/bbpress/topic.php?id=9611&replies=1#post-11585
http://thesweepspot.com/forum/topic/wwwlouisvuittonwalletukusacom-jw65252#post-667298
http://www.roomthebook.com/walls/viewtopic.php?f=14&t=563664&p=621962#p621962
http://www.amusic.de/node/93488
http://social.makanchi.kz/members/usazwyhit/activity/10466
http://www.mymonda.de/bbpress/topic.php?id=19597&replies=1#post-28132
http://ekstasisdance.com/community/topic.php?id=198250&replies=1#post-205395
http://pro.cleverinvestor.com/knowledge/topic.php?id=18419&replies=1#post-20087
http://schoolofeducators.com/members/usahumblepg/activity/180784
http://stuff.avenathus.com/forum/topic/wwwlouisvuittonwalletukusacom-ens8550098?replies=1#post-174167
http://pulejawan.pk/members/usatqueqa/activity/12438
http://studioeightphotographycourses.co.uk/student-forum/topic.php?id=76740&replies=1#post-87537
http://scuola007.altervista.org/social/members/usakaybqv/activity/2813
http://www.followmyego.com/view/post:156394
http://www.businessdeaf.ru/bbpress/topic.php?id=1481&replies=1#post-1628
http://womanlifeweb.net/ku/topic.php?id=12345&replies=1#post-13901
http://okutamaclimbing.com/bbpress/topic.php?id=12842&replies=1#post-19060
http://wearedocs.com/members/usanjsayh/activity/109777
http://egliseenmission-evangelisation.org/forum1/topic.php?id=386729&replies=1#post-408782
http://www.lcplunderground.com/view/post:281082
http://www.mydestinlife.com/forum/viewtopic.php?f=19&t=174209
http://bmm.org.za/node/2#comment-226229
http://petrabook.com/profile.php?user=38197&v=comments
http://bbs.bjadks.cn/showtopic-30633.aspx
http://www.pibla.de/pix/displayimage.php?pos=-2563
http://www.yazj.cn/yazj/read.php?tid=100741&ds=1
http://kpgp.kr/index.php/User:Uqmlaywawbg#FT1096--spun50
http://www.1pjd.de/index.php?site=forum_topic&topic=1
http://art.miratopia.com/?q=node/4#comment-58973
http://www.hkhobby.com/forum/viewthread.php?tid=248029&extra=page%3D1
http://mxyxy.com.h001.360iis.net/apps.php?q=diary&a=detail&did=253378&uid=29143
http://www.corridosalterados.com/showthread.php?9226-www-cheaplouisvuittonwalletsny-com-Bbap10&p=33434#post33434
http://www.bplanproject.eu/forum_en/index.php?topic=327924.msg421511#msg421511
http://stroitforum.com/showthread.php?p=5855#post5855
http://euros-embedded.com/wiki/index.php/User:Marfnbgrdhr#FT1016--spun76
http://www.hlzyz.org/bbs/boke.asp?cthweklcfpd.showtopic.64177.html
http://bbs.fjzippo.com/forum.php?mod=viewthread&tid=254772
http://capne.net/bbPress/topic.php?id=793321&replies=1#post-832533
http://realdeeprecordings.com/forum/topic/315450?replies=1#post-317223
http://yournetbank.com/showthread.php?246-www.cheaplouisvuittonbagsfr.com-dTic31&p=450#post450
buy tramadol online tramadol hcl para que sirve - tramadol 50mg street price
xanax no prescription online where to order xanax - xanax overdose side effects
order xanax xanax g3720 - xanax drug price
buy tramadol online tramadol ultram fibromyalgia - buy tramadol saturday delivery
tramadol without prescription buy tramadol 6914 - buy tramadol hcl 50mg
xanax online can you order xanax online - xanax 2mg purepac
buy tramadol online tramadol hcl 627 - buy tramadol online cheap
generic xanax xanax effects on dogs - xanax bars g3722 effects
coach outlet kphsmptx coach usa hvhfzkex coach factory outlet kfaltdsi coach factory cqzxrsvl
generic xanax xanax bars injecting - xanax dosage .75
buy tramadol online tramadol hydrochloride 50 mg effects - tramadol overdose how much
xanax 1mg xanax drug of abuse - pictures generic xanax 1 mg
buy carisoprodol carisoprodol 350 mg generic - carisoprodol max dosage
buy tramadol no prescription tramadol hcl 50 mg high - tramadol 100
buy tramadol online buy tramadol online without rx - buy tramadol online usa pharmacy
buy tramadol online where should i buy tramadol from online - tramadol hcl 50 mg recreational use
buy tramadol online tramadol pain killer - tramadol 627 get high
buy tramadol online tramadol withdrawal vertigo - tramadol 50 mg price per pill
buy tramadol online canadian tramadol no prescription - buy tramadol online prescription
buy tramadol online tramadol hcl and zoloft - buying tramadol with mastercard
buy tramadol tramadol 50 mg with tylenol - where to buy tramadol online usa
buy cialis online buy cialis professional cheap - cialis online+toronto
buy tramadol online order tramadol in florida - tramadol hcl er 100mg
buy tramadol online tramadol equivalent - tramadol for dogs addiction
xanax 1mg generic xanax effectiveness - what does 1mg xanax look like
buy cialis generic order cialis from us - where to buy cheap cialis online
cialis online usa buy cheap cialis no prescription - buy cialis soft online
buy cialis online cialis online ricetta - generic cialis online overnight
xanax online xanax mexico - xanax effects long term use
learn how to buy tramdadol tramadol hydrochloride 50mg tablets - tramadol effects
order tramadol online cod tramadol no prescription free shipping - tramadol no prescription
learn how to buy tramdadol tramadol like ultram - tramadol used get high
buy tramadol buy tramadol health solutions network - can you buy tramadol
buy tramadol cheap tramadol on line - tramadol 50mg like
buy tramadol tramadol and breastfeeding - tramadol withdrawal day 3
buy tramadol cheap tramadol no prescription - order tramadol online no prescription overnight
buy tramadol cod next day delivery tramadol 50mg dosage - buy tramadol online without script
buy tramadol tramadol sale no prescription - tramadol 50mg dosage for dogs
http://landvoicelearning.com/#21906 tramadol hcl 50 mg addiction - where to buy tramadol cod
learn how to buy tramdadol tramadol for dogs addictive - tramadol hydrochloride 50mg overdose
order tramadol online tramadol 50mg tablets narcotic - buy viagra tramadol
tramadol online tramadol contraindications - get tramadol online no prescription
buy tramadol online tramadol ultram side effects dogs - tramadol ultram withdrawal
buy tramadol 30 tramadol 50mg - buy tramadol overnight cod
http://reidmoody.com/#45570 70 mg ativan - dosage of ativan
cheap ativan online ativan vs xanax flying anxiety - ativan overdose side effects
tramadol online troy hill pharmacy online tramadol - tramadol 50 mg vs oxycodone 30 mg
ways to buy ativan online ativan withdrawal pain - can overdose ativan fatal
http://reidmoody.com/#51208 are ativan and xanax the same - ativan withdrawal blood pressure
http://ranchodelastortugas.com/#37284 xanax high blood pressure medication - oxycontin xanax drug interactions
buy tramadol online mastercard overnight tramadol 50 mg vs vicodin - tramadol (ultram) 50 mg tablet
http://staam.org/#90873 tramadol dosage adults - tramadol hcl 50 mg canine
http://ranchodelastortugas.com/#71453 2mg xanax urine - round xanax 1mg
buy tramadol online tramadol withdrawal leg cramps - ultram er tramadol hcl
buy tramadol online buy tramadol for dogs online - buy cheap tramadol online cod
http://ranchodelastortugas.com/#58720 overdose with xanax and alcohol - xanax no prescription united states
Post a Comment